Add assertions to try to catch IPcheck counting errors.
authorMichael Poole <mdpoole@troilus.org>
Sat, 19 Mar 2005 23:22:09 +0000 (23:22 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 19 Mar 2005 23:22:09 +0000 (23:22 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1329 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/IPcheck.h
ircd/IPcheck.c
ircd/m_nick.c
ircd/s_serv.c
ircd/s_user.c

index 0e8f7b6810765ccc2531d2c075443e3e1dbfe0b3..61af3fb33eded479936874a218e7f3278f17266d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-03-19  Michael Poole <mdpoole@troilus.org>
+
+       * include/IPcheck.h (IPcheck_connect_fail): Take a Client
+       parameter instead of irc_in_addr.
+
+       * ircd/IPcheck.c (IPcheck_connect_fail): Likewise.  Assert that
+       the client has been IP-checked.
+       (IPcheck_remote_connect): Assert that the client has not yet been
+       charged for connecting.
+       (IPcheck_connect_succeeded): Assert that the client has been
+       charged for connecting.
+       (IPcheck_disconnect): Likewise.
+
+       * ircd/m_nick.c (m_nick): Pass rejected client to
+       IPcheck_connect_fail() when somebody takes the nick first.
+       (ms_nick): Likewise.
+
+       * ircd/s_serv.c (server_estab): Pass new server to
+       IPcheck_connect_fail().
+
+       * ircd/s_user.c (register_user): When rejecting a user, pass
+       the struct Client to IPcheck_connect_fail().
+
 2005-03-19  Michael Poole <mdpoole@troilus.org>
 
        * doc/example.conf (Connect): Remove a buggy comment about leaf
index 19e9cfb8122d0f103d32c86819b91e40ac454744..493ef4367fe0812721d0136ac6bfb68d8e73f106 100644 (file)
@@ -18,7 +18,7 @@ struct irc_in_addr;
  */
 extern void IPcheck_init(void);
 extern int IPcheck_local_connect(const struct irc_in_addr *ip, time_t *next_target_out);
-extern void IPcheck_connect_fail(const struct irc_in_addr *ip);
+extern void IPcheck_connect_fail(const struct Client *cptr);
 extern void IPcheck_connect_succeeded(struct Client *cptr);
 extern int IPcheck_remote_connect(struct Client *cptr, int is_burst);
 extern void IPcheck_disconnect(struct Client *cptr);
index 7c0b6aab4f06fb0ef290c825311aebda16dd5644..837ed0141ee6c4e9500c3a745bc7d79888e70cb5 100644 (file)
@@ -513,6 +513,7 @@ int IPcheck_local_connect(const struct irc_in_addr *a, time_t* next_target_out)
 int IPcheck_remote_connect(struct Client *cptr, int is_burst)
 {
   assert(0 != cptr);
+  assert(!IsIPChecked(cptr));
   return ip_registry_check_remote(cptr, is_burst);
 }
 
@@ -521,9 +522,10 @@ int IPcheck_remote_connect(struct Client *cptr, int is_burst)
  * so the client's address is not penalized for the failure.
  * @param[in] a Address of rejected client.
  */
-void IPcheck_connect_fail(const struct irc_in_addr *a)
+void IPcheck_connect_fail(const struct Client *cptr)
 {
-  ip_registry_connect_fail(a);
+  assert(IsIPChecked(cptr));
+  ip_registry_connect_fail(&cli_ip(cptr));
 }
 
 /** Handle a client that has successfully connected.
@@ -535,6 +537,7 @@ void IPcheck_connect_fail(const struct irc_in_addr *a)
 void IPcheck_connect_succeeded(struct Client *cptr)
 {
   assert(0 != cptr);
+  assert(IsIPChecked(cptr));
   ip_registry_connect_succeeded(cptr);
 }
 
@@ -546,6 +549,7 @@ void IPcheck_connect_succeeded(struct Client *cptr)
 void IPcheck_disconnect(struct Client *cptr)
 {
   assert(0 != cptr);
+  assert(IsIPChecked(cptr));
   ip_registry_disconnect(cptr);
 }
 
index 18ecca5746c96994bfc82a57a33ecc4c016684aa..8b5a659d99946d7acbdb8545b8bec2205f474832 100644 (file)
@@ -247,8 +247,8 @@ int m_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    * the message below.
    */
   if (IsUnknown(acptr) && MyConnect(acptr)) {
-    ++ServerStats->is_ref;
-    IPcheck_connect_fail(&cli_ip(acptr));
+    ServerStats->is_ref++;
+    IPcheck_connect_fail(acptr);
     exit_client(cptr, acptr, &me, "Overridden by other sign on");
     return set_nick_name(cptr, sptr, nick, parc, parv);
   }
@@ -378,7 +378,7 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (IsUnknown(acptr) && MyConnect(acptr))
   {
     ServerStats->is_ref++;
-    IPcheck_connect_fail(&cli_ip(acptr));
+    IPcheck_connect_fail(acptr);
     exit_client(cptr, acptr, &me, "Overridden by other sign on");
     return set_nick_name(cptr, sptr, nick, parc, parv);
   }
index 24915e952cb5357cba49b2acc0a3e96827007e93..7a6d68570498771045488845f6660404ace74477 100644 (file)
@@ -138,7 +138,7 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf)
      * XXX - if this comes from a server port, it will not have been added
      * to the IP check registry, see add_connection in s_bsd.c
      */
-    IPcheck_connect_fail(&cli_ip(cptr));
+    IPcheck_connect_fail(cptr);
   }
 
   det_confs_butmask(cptr, CONF_SERVER | CONF_UWORLD);
index 364ddd3b86d58392bf635b9e2784e3824b9aceed..5ecf6b61e62d7381593a5e3a59efea85e9833a81 100644 (file)
@@ -434,7 +434,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
                                get_client_name(sptr, SHOW_IP));
         }
         ++ServerStats->is_ref;
-        IPcheck_connect_fail(&cli_ip(sptr));
+        IPcheck_connect_fail(sptr);
         return exit_client(cptr, sptr, &me,
                            "Sorry, your connection class is full - try "
                            "again later or try another server");
@@ -453,7 +453,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
         /* Can this ever happen? */
       case ACR_BAD_SOCKET:
         ++ServerStats->is_ref;
-        IPcheck_connect_fail(&cli_ip(sptr));
+        IPcheck_connect_fail(sptr);
         return exit_client(cptr, sptr, &me, "Unknown error -- Try again");
     }
     ircd_strncpy(user->host, cli_sockhost(sptr), HOSTLEN);