Forward port IPcheck bug fixes and asserts from 2.10.11.
[ircu2.10.12-pk.git] / ircd / IPcheck.c
index 8e9e353201a35f869ec0d5ba5ccaf2e7b3afb033..b9e69e1d52fb1b9d6fb22ba14f4945141645f54f 100644 (file)
@@ -244,7 +244,10 @@ int ip_registry_check_local(unsigned int addr, time_t* next_target_out)
    * Don't allow more then 255 connects from one IP number, ever
    */
   if (0 == ++entry->connected)
+  {
+    entry->connected--;
     return 0;
+  }
 
   if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_PERIOD)
     entry->attempts = 0;
@@ -266,6 +269,7 @@ int ip_registry_check_local(unsigned int addr, time_t* next_target_out)
 #ifdef NOTHROTTLE 
     return 1;
 #else
+    assert(entry->connected > 0);
     --entry->connected;
     return 0;
 #endif        
@@ -337,7 +341,10 @@ void ip_registry_connect_fail(unsigned int addr)
 {
   struct IPRegistryEntry* entry = ip_registry_find(addr);
   if (entry)
-    --entry->attempts;
+  {
+    if (0 == --entry->attempts)
+      ++entry->attempts;
+  }
 }
 
 /*
@@ -392,6 +399,7 @@ void ip_registry_disconnect(struct Client *cptr)
   /*
    * If this was the last one, set `last_connect' to disconnect time (used for expiration)
    */
+  /* assert(entry->connected > 0); */
   if (0 == --entry->connected) {
     if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_LIMIT * IPCHECK_CLONE_PERIOD) {
       /*