From: Michael Poole Date: Sat, 19 Mar 2005 23:22:09 +0000 (+0000) Subject: Add assertions to try to catch IPcheck counting errors. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=7acf6017c040df7a3bc673c298e3450b3002bac6 Add assertions to try to catch IPcheck counting errors. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1329 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 0e8f7b6..61af3fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2005-03-19 Michael Poole + + * 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 * doc/example.conf (Connect): Remove a buggy comment about leaf diff --git a/include/IPcheck.h b/include/IPcheck.h index 19e9cfb..493ef43 100644 --- a/include/IPcheck.h +++ b/include/IPcheck.h @@ -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); diff --git a/ircd/IPcheck.c b/ircd/IPcheck.c index 7c0b6aa..837ed01 100644 --- a/ircd/IPcheck.c +++ b/ircd/IPcheck.c @@ -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); } diff --git a/ircd/m_nick.c b/ircd/m_nick.c index 18ecca5..8b5a659 100644 --- a/ircd/m_nick.c +++ b/ircd/m_nick.c @@ -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); } diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 24915e9..7a6d685 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -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); diff --git a/ircd/s_user.c b/ircd/s_user.c index 364ddd3..5ecf6b6 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -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);