#include "msg.h"
#include "numnicks.h" /* NumNick, NumServ (GODMODE) */
#include "ircd_alloc.h"
+#include "ircd_events.h"
#include "s_debug.h" /* Debug */
#include "s_user.h" /* TARGET_DELAY */
#include "send.h"
static struct IPRegistryEntry* hashTable[IP_REGISTRY_TABLE_SIZE];
static struct IPRegistryEntry* freeList = 0;
+static struct Timer expireTimer;
+
static unsigned int ip_registry_hash(unsigned int ip)
{
return ((ip >> 16) ^ ip) & (IP_REGISTRY_TABLE_SIZE - 1);
}
}
-/*
- * ip_registry_expire
- */
-static void ip_registry_expire()
+/* Callback to run an expiry of the IPcheck registry */
+static void ip_registry_expire(struct Event* ev)
{
int i;
struct IPRegistryEntry* entry;
struct IPRegistryEntry* entry_next;
+ assert(ET_EXPIRE == ev_type(ev));
+ assert(0 != ev_timer(ev));
+
for (i = 0; i < IP_REGISTRY_TABLE_SIZE; ++i) {
for (entry = hashTable[i]; entry; entry = entry_next) {
entry_next = entry->next;
}
}
+/*
+ * IPcheck_init()
+ *
+ * Initializes the registry timer
+ */
+void IPcheck_init(void)
+{
+ timer_add(&expireTimer, ip_registry_expire, 0, TT_PERIODIC, 60);
+}
+
/*
* IPcheck_local_connect
*
free_targets = entry->target->count;
tr = " tr";
}
- sendcmdto_one(&me, CMD_NOTICE, cptr, ":on %u ca %u(%u) ft %u(%u)%s",
- entry->connected, entry->attempts, IPCHECK_CLONE_LIMIT,
+ sendcmdto_one(&me, CMD_NOTICE, cptr, "%C :on %u ca %u(%u) ft %u(%u)%s",
+ cptr, entry->connected, entry->attempts, IPCHECK_CLONE_LIMIT,
free_targets, STARTTARGETS, tr);
}
assert(0 != cptr);
return ip_registry_count(cli_ip(cptr).s_addr);
}
-
-void IPcheck_expire()
-{
- static time_t next_expire = 0;
- if (next_expire < CurrentTime) {
- ip_registry_expire();
- next_expire = CurrentTime + 60;
- }
-}
-
-