X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2FIPcheck.c;h=67b34851cb8fe0bbe4ce905040c4ff1179e81c83;hb=894ccd3b8d5acb0067562d26bf72228d3e617203;hp=0887fe2acdf52f377978d76f106dc5a1264abb7f;hpb=d5a5b946305de3c438e4941a0a34911ab3252584;p=ircu2.10.12-pk.git diff --git a/ircd/IPcheck.c b/ircd/IPcheck.c index 0887fe2..67b3485 100644 --- a/ircd/IPcheck.c +++ b/ircd/IPcheck.c @@ -160,7 +160,7 @@ static void ip_registry_remove(struct IPRegistryEntry* entry) * For members that have a sensible default value, that is used. * @return Newly allocated registry entry. */ -static struct IPRegistryEntry* ip_registry_new_entry() +static struct IPRegistryEntry* ip_registry_new_entry(void) { struct IPRegistryEntry* entry = freeList; if (entry) @@ -373,13 +373,20 @@ int ip_registry_check_remote(struct Client* cptr, int is_burst) * of their own. This "undoes" the effect of ip_registry_check_local() * so the client's address is not penalized for the failure. * @param[in] addr Address of rejected client. + * @param[in] disconnect If true, also count the client as disconnecting. */ -void ip_registry_connect_fail(const struct irc_in_addr *addr) +void ip_registry_connect_fail(const struct irc_in_addr *addr, int disconnect) { struct IPRegistryEntry* entry = ip_registry_find(addr); - if (entry && 0 == --entry->attempts) { - Debug((DEBUG_DNS, "IPcheck noting local connection failure for %s.", ircd_ntoa(&entry->addr))); - ++entry->attempts; + if (entry) { + if (0 == --entry->attempts) { + Debug((DEBUG_DNS, "IPcheck noting local connection failure for %s.", ircd_ntoa(&entry->addr))); + ++entry->attempts; + } + if (disconnect) { + assert(entry->connected > 0); + entry->connected--; + } } } @@ -521,11 +528,12 @@ int IPcheck_remote_connect(struct Client *cptr, int is_burst) * of their own. This "undoes" the effect of ip_registry_check_local() * so the client's address is not penalized for the failure. * @param[in] cptr Client who has been rejected. + * @param[in] disconnect If true, also count the client as disconnecting. */ -void IPcheck_connect_fail(const struct Client *cptr) +void IPcheck_connect_fail(const struct Client *cptr, int disconnect) { assert(IsIPChecked(cptr)); - ip_registry_connect_fail(&cli_ip(cptr)); + ip_registry_connect_fail(&cli_ip(cptr), disconnect); } /** Handle a client that has successfully connected.