]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
patch from div0 that removes connect flood ban when a player disconnects (this preven...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 9 Nov 2006 10:16:16 +0000 (10:16 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 9 Nov 2006 10:16:16 +0000 (10:16 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6617 d7cf8633-e32d-0410-b094-e92efae38249

netconn.c

index d848411d6c5193912060a3ddd254e44c2060bab0..d876b929e2a6baab2b9e6e74b002fd7a625bf05f 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -787,10 +787,15 @@ netconn_t *NetConn_Open(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress)
        return conn;
 }
 
+void NetConn_ClearConnectFlood(lhnetaddress_t *peeraddress);
 void NetConn_Close(netconn_t *conn)
 {
        netconn_t *c;
        // remove connection from list
+
+       // allow the client to reconnect immediately
+       NetConn_ClearConnectFlood(&(conn->peeraddress));
+
        if (conn == netconn_list)
                netconn_list = conn->next;
        else
@@ -1753,6 +1758,7 @@ static qboolean NetConn_PreventConnectFlood(lhnetaddress_t *peeraddress)
                                // renew the ban on this address so it does not expire
                                // until the flood has subsided
                                sv.connectfloodaddresses[floodslotnum].lasttime = realtime;
+                               //Con_Printf("Flood detected!\n");
                                return true;
                        }
                        // the flood appears to have subsided, so allow this
@@ -1763,9 +1769,30 @@ static qboolean NetConn_PreventConnectFlood(lhnetaddress_t *peeraddress)
        // begin a new timeout on this address
        sv.connectfloodaddresses[bestfloodslotnum].address = noportpeeraddress;
        sv.connectfloodaddresses[bestfloodslotnum].lasttime = realtime;
+       //Con_Printf("Flood detection initiated!\n");
        return false;
 }
 
+void NetConn_ClearConnectFlood(lhnetaddress_t *peeraddress)
+{
+       int floodslotnum;
+       lhnetaddress_t noportpeeraddress;
+       // see if this is a connect flood
+       noportpeeraddress = *peeraddress;
+       LHNETADDRESS_SetPort(&noportpeeraddress, 0);
+       for (floodslotnum = 0;floodslotnum < MAX_CONNECTFLOODADDRESSES;floodslotnum++)
+       {
+               if (sv.connectfloodaddresses[floodslotnum].lasttime && LHNETADDRESS_Compare(&noportpeeraddress, &sv.connectfloodaddresses[floodslotnum].address) == 0)
+               {
+                       // this address matches an ongoing flood address
+                       // remove the ban
+                       sv.connectfloodaddresses[floodslotnum].address.addresstype = LHNETADDRESSTYPE_NONE;
+                       sv.connectfloodaddresses[floodslotnum].lasttime = 0;
+                       //Con_Printf("Flood cleared!\n");
+               }
+       }
+}
+
 extern void SV_SendServerinfo (client_t *client);
 static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *data, int length, lhnetaddress_t *peeraddress)
 {