Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: [Q3 FIX] Q3 fake clients fix

  1. #1
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts

    [Q3 FIX] Q3 fake clients fix

    Hello, I want to share my Q3fill fix.
    Script will kick player which tries to connect to the server when other player on server has same IP address.
    The code is not diffucult but it can help to prevent annoying server haters ^^.

    NOTICE: Requires libcod!

    PHP Code:
    notifyConnecting()
    {
        
    self endon("disconnect");

        
    waittillframeend;

        if(
    isDefined(self))
        {
            
    level notify("connecting",self);
            
    setQ3Fix(); //Add this line
        
    }
        
        
    }
    setQ3Fix()
    {
        if(!
    isDefined(level.q3_fix))
            
    level.q3_fix = [];
            
        
    my_ip getIP(self);
        
        if(
    isDefined(level.q3_fix[my_ip]) && !self.data["bot"])
        {
            
    self setClientCvar("com_errorTitle""Error"); //Maybe somehow system will fail (it should'nt but we should always assume that can happens) and a real client can be kicked.
            
    self setClientCvar("com_errorMessage""IP duplicate detected"); //So let him know, what went wrong.
            
    self.kicked true;
            
    println("Warning: Kicking client with IP duplicate: "+my_ip);
            
    kick(self getEntityNumber());
            return 
    true;
        }
        
        if(!
    self.data["bot"])
            
    level.q3_fix[my_ip] = true;
            
        return 
    false;
    }
    getIP(client

        return 
    closer(430client getEntityNumber()); 
    }
    println(msg)
    {
        
    closer(200msg "\n");
    }
    Callback_PlayerDisconnect()
    {
      if(!
    isDefined(self.kicked))
          
    level.q3_fix[getIP(self)] = undefined;
      [...]

    Results:

    PHP Code:
    Going from CS_FREE to CS_CONNECTED for  (num 0 guid 0)
    Sending heartbeat to cod2master.activision.com
    Client 3 connecting with 50 challenge ping from SOMEIP
    :SOMEPORT
    Going from CS_FREE to CS_CONNECTED 
    for  (num 1 guid 0)
    WarningKicking client with IP duplicateSOMEIP
    WARNING
    Non-localized Game Message string is not allowed to have letters in itMust be changed over to a localized string"^4*^7 t0nj3WO345oa ^7Ha^9s ^7Disc^9onnected ^7Fr^9om ^4*^7eXtremE^2~^9ZOMBIES^7"
    1EXE_PLAYERKICKED 
    You can see self.data["bot"] which is boolean in my case. You should define your own variable to know if connecting entity is a bot (to prevent testclient kicking).
    Also you can add a line which adds kicked IP into a logfile. Then you can easily add it manually into firewall (or do whatever you need).

    If you got any questions or objections to my code please let me know below

    Edit#1: I forget to add array undefining when a real player disconnects
    Last edited by RobsoN; 14th January 2014 at 18:11.
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  2. The Following 3 Users Say Thank You to RobsoN For This Useful Post:

    kung foo man (15th January 2014),Rocky (14th January 2014),smect@ (15th January 2014)

  3. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Maybe add a 10 or 15 seconde delay and add endon on 'begin'. When you receive 'begin' then it isn't a fake client.

    Edit: is self defined when it is a fake client?
    Last edited by Mitch; 14th January 2014 at 17:52. Reason: connected is a global notify, but begin isn't

  4. #3
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    Maybe add a 10 or 15 seconde delay and add endon on 'begin'. When you receive 'begin' then it isn't a fake client.
    I didn't tested anything with "begin" notify but I will soon.

    Edit: is self defined when it is a fake client?
    Yeah, self is defined.
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  5. #4
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    This is my fix. It requires my libcod version with lastmsg.

    PHP Code:
    kickFakeClients()
    {
        
    self endon("begin");
        
        
    wait 15;

        
    lastmsg std\player::getLastMsg();

        if(
    lastmsg 50000)
        {
            
    ip std\player::getIP();
            
    iprintln(self.name "^7 connection timeout.");
            
    std\io::println("[CONNECTION TIMEOUT]: " self.name " (" ip ")");
            
    kick(self getEntityNumber());
        }

    std\player
    PHP Code:
    getLastMsg() { return closer(432self getEntityNumber()); } 
    libcod: http://znation.nl/libcod/
    https://github.com/M-itch/libcod/com...92938c9b93ec4e

  6. The Following 3 Users Say Thank You to Mitch For This Useful Post:

    kung foo man (12th February 2014),RobsoN (11th February 2014),Rocky (12th February 2014)

  7. #5
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    I improved my code a bit
    PHP Code:
    main()
    {
        
    level.connectingip = [];

    PHP Code:
    kickFakeClients(ip)
    {
        
    self endon("begin");
        
    self endon("disconnect");

        
    delay 5;
        
    max 5000;
        
        if(!
    isDefined(level.connectingip[ip])) // less strict for first connection
        
    {
            
    level.connectingip[ip] = 1;
            
    max 50000;
            
    delay 30;
        }        

        
    wait delay;

        
    lastmsg std\player::getLastMsg();

        if(
    lastmsg max)
        {
            if(
    delay == 30 && isDefined(level.connectingip[ip]))
                
    level.connectingip[ip] = undefined// prevent strict rules for crashed clients

            
    iprintln(self.name "^7 connection timeout.");
            
    std\io::println("[CONNECTION TIMEOUT]: " self.name " (" ip ")");
            
    kick(self getEntityNumber());
        }

    PHP Code:
    ip std\player::getIP();
    self thread kickFakeClients(ip);
    self.statusicon "hud_status_connecting";
    self waittill("begin");
    self.statusicon "";

    if(
    isDefined(level.connectingip[ip]))
        
    level.connectingip[ip] = undefined
    Last edited by Mitch; 12th February 2014 at 19:23.