Raised This Month: $51 Target: $400
 12% 

How to check server ip/port


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 08-21-2013 , 05:22   How to check server ip/port
Reply With Quote #1

Hello all.


I am looking for a way to check current server ip/port to list it on MySQL.

The problem is retreiving values from 'ip' and 'port' is not correct, because it can be faked/seted incorrectly. I guess it can be done with sockets, but i have no knowledges on it completely.

Can someone give me an idea how to retreive correct ip and port, please?
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-21-2013 , 08:01   Re: How to check server ip/port
Reply With Quote #2

get_user_ip(0
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 08-21-2013 , 09:51   Re: How to check server ip/port
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
get_user_ip(0
It's just retreiving values 'ip' and 'port', which can be changed/misconfigured easily. I am looking for a way to detect ip correctly.
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-21-2013 , 10:01   Re: How to check server ip/port
Reply With Quote #4

Quote:
Originally Posted by Mofforg View Post
It's just retreiving values 'ip' and 'port', which can be changed/misconfigured easily. I am looking for a way to detect ip correctly.
Try this:

PHP Code:
#include <amxmodx>

new p_Address;

public 
plugin_init()
{
    
register_plugin("Server Address",AMXX_VERSION_STR,"Amxx Dev Team");

    
p_Address get_cvar_pointer("net_address");

    
register_concmd("amx_server_ip","cmdIP");
}

public 
cmdIP(id)
{
    new 
szAddress[32];
    
get_pcvar_string(p_Address,szAddress,charsmax(szAddress));

    
client_print(id,print_chat,"[AMXX] Server IP %s",szAddress);

    return 
PLUGIN_HANDLED;

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-21-2013 , 10:02   Re: How to check server ip/port
Reply With Quote #5

That is retrieving the IP and Port the server is configured to use. If you want some other method, then use Sockets and a Web Site to obtain the IP
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 08-21-2013 , 10:09   Re: How to check server ip/port
Reply With Quote #6

Quote:
Originally Posted by ^SmileY View Post
Try this:

PHP Code:
#include <amxmodx>

new p_Address;

public 
plugin_init()
{
    
register_plugin("Server Address",AMXX_VERSION_STR,"Amxx Dev Team");

    
p_Address get_cvar_pointer("net_address");

    
register_concmd("amx_server_ip","cmdIP");
}

public 
cmdIP(id)
{
    new 
szAddress[32];
    
get_pcvar_string(p_Address,szAddress,charsmax(szAddress));

    
client_print(id,print_chat,"[AMXX] Server IP %s",szAddress);

    return 
PLUGIN_HANDLED;

It can be changed with console.... I could not rely on cvars.
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-21-2013 , 10:18   Re: How to check server ip/port
Reply With Quote #7

What IP are you trying to obtain? Why do you need this IP? Why can you not use the IP returned by HLDS or by the CVARs?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 08-21-2013 , 10:27   Re: How to check server ip/port
Reply With Quote #8

Quote:
Originally Posted by YamiKaitou View Post
What IP are you trying to obtain? Why do you need this IP? Why can you not use the IP returned by HLDS or by the CVARs?
I used to make a plugin, which should know server IP to choose how to react. But if some guy would place the wrong ip, it could break my system or damage other users. That's why i need to make it protected. How to use sockets for this?
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 08-21-2013 , 11:32   Re: How to check server ip/port
Reply With Quote #9

Quote:
Originally Posted by Mofforg View Post
But if some guy would place the wrong ip, it could break my system or damage other users.
Mind Clearing it a bit ? How will the placing the wrong Ip break your system or damage other users ?
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then
devilicioux is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 08-21-2013 , 11:39   Re: How to check server ip/port
Reply With Quote #10

Quote:
Originally Posted by devilicioux View Post
Mind Clearing it a bit ? How will the placing the wrong Ip break your system or damage other users ?
The system is designed this way. It making actions depending on server state. If the IP defined incorrectly, then it would be messed up and working in a wrong way.
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode