+2012-10-15 Michael Poole <mdpoole@troilus.org>
+
+ * include/IPcheck.h (IPcheck_connect_fail): Add new 'disconnect'
+ parameter. This treats the failure as a disconnection from the
+ client's current IP address.
+
+ * ircd/IPcheck.c (ip_registry_connect_fail): Likewise.
+ (IPcheck_connect_fail): Pass it through.
+
+ * ircd/m_nick.c (m_nick): Pass zero for the new parameter.
+ (ms_nick): Likewise.
+
+ * ircd/s_auth.c (preregister_user): Likewise.
+ (iauth_cmd_ip_address): Pass one for the new parameter.
+
2012-06-20 Michael Poole <mdpoole@troilus.org>
* ircd/ircd_string.c (ipmask_parse): Return zero if there is junk
*/
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 Client *cptr);
+extern void IPcheck_connect_fail(const struct Client *cptr, int disconnect);
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);
* 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--;
+ }
}
}
* 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.
*/
if (IsUnknown(acptr) && MyConnect(acptr)) {
ServerStats->is_ref++;
- IPcheck_connect_fail(acptr);
+ IPcheck_connect_fail(acptr, 0);
exit_client(cptr, acptr, &me, "Overridden by other sign on");
return set_nick_name(cptr, sptr, nick, parc, parv);
}
if (IsUnknown(acptr) && MyConnect(acptr))
{
ServerStats->is_ref++;
- IPcheck_connect_fail(acptr);
+ IPcheck_connect_fail(acptr, 0);
exit_client(cptr, acptr, &me, "Overridden by other sign on");
return set_nick_name(cptr, sptr, nick, parc, parv);
}
/* Can this ever happen? */
case ACR_BAD_SOCKET:
++ServerStats->is_ref;
- IPcheck_connect_fail(cptr);
+ IPcheck_connect_fail(cptr, 0);
return exit_client(cptr, cptr, &me, "Unknown error -- Try again");
}
return 0;
memcpy(&auth->original, &cli_ip(cli), sizeof(auth->original));
/* Undo original IP connection in IPcheck. */
- IPcheck_connect_fail(cli);
+ IPcheck_connect_fail(cli, 1);
ClearIPChecked(cli);
/* Update the IP and charge them as a remote connect. */