Server Protection
#1

Hi,i made a code for server port and ip check,but i want a better and optimized code,also i want it allow running on localhost,this code closes the server everytime,i added the bind and port in server.cfg file

PHP код:
        new ServerIp[16];
        
GetServerVarAsString("bind"ServerIpsizeof(ServerIp));
        if(
strcmp(ServerIpSERVER_IPfalse)!=|| isnull(ServerIp))
        {
            if((
strcmp(ServerIp"127.0.0.1"false) != 0) || (strcmp(ServerIp"localhost"false) != 0) || isnull(ServerIp)){
            } else { 
SendRconCommand("exit"); print("The ip and port is not correct"); }
        }
        if(
GetServerVarAsInt("port") != SERVER_PORT)
        {
            
SendRconCommand("exit");
        } 
Reply
#2

PHP код:
        new ServerIp[16]; 
        
GetServerVarAsString("bind"ServerIpsizeof(ServerIp)); 
        if(
strcmp(ServerIpSERVER_IPfalse)!=|| isnull(ServerIp)) 
        { 
            if((
strcmp(ServerIp"127.0.0.1"false) != && strcmp(ServerIp"localhost"false) != 0) || isnull(ServerIp)) {SendRconCommand("exit"); print("The ip and port is not correct"); }
        } 
        if(
GetServerVarAsInt("port") != SERVER_PORT
        { 
            
SendRconCommand("exit"); 
        } 
Reply
#3

LOL,what change you made?
Reply
#4

logic change, so that it will work as you want, on localhost and 127.0.0.1
Reply
#5

Use
https://sampforum.blast.hk/showthread.php?tid=600408
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)