#define HOOK_NICK_MODEOPER 307 /* Argument is void*[2] (nick, modes) */
#define HOOK_NICK_KILL 308 /* Argument is void*[2] (nick, reason) */
#define HOOK_NICK_MASKPRIVMSG 309 /* Argument is void*[3] (nick, target, message) ** NICK COULD BE NULL ** */
-#define HOOK_NICK_MOVENODE 310 /* Argument is void*[2] (nick, oldnode) */
#define HOOK_CHANNEL_BURST 400 /* Argument is channel pointer */
#define HOOK_CHANNEL_CREATE 401 /* Argument is void*[2] (channel, nick) */
return buf;
}
-/*
- * setipnodebits:
- * Moves the nick to a different ipnode.
- */
-void setipnodebits(nick *np, int bits) {
- struct irc_in_addr ipaddress;
- patricia_node_t *oldnode;
- void *harg[2];
-
- if(np->ipnode->prefix->bitlen == bits)
- return;
-
- memcpy(&ipaddress, &np->p_nodeaddr, sizeof(ipaddress));
- node_decrement_usercount(np->ipnode);
- oldnode = np->ipnode;
- np->ipnode = refnode(iptree, &ipaddress, bits);
- node_increment_usercount(np->ipnode);
-
- harg[0] = np;
- harg[1] = oldnode;
- triggerhook(HOOK_NICK_MOVENODE, harg);
-
- derefnode(iptree, oldnode);
-}
-
#if 0
/*
void releasenickext(int index);
char *visiblehostmask(nick *np, char *buf);
char *visibleuserhost(nick *np, char *buf);
-void setipnodebits(nick *np, int bits);
/* nickhandlers.c functions */
int handlenickmsg(void *source, int cargc, char **cargv);
registerhook(HOOK_NICK_NEWNICK, &pn_hook_newuser);
registerhook(HOOK_NICK_LOSTNICK, &pn_hook_lostuser);
- registerhook(HOOK_NICK_MOVENODE, &pn_hook_nodemoveuser);
registercontrolhelpcmd("nodeuserlist", NO_OPER, 1, &pn_cmd_nodeuserlist, "Usage: nodeuserlist <ipv4|ipv6|cidr4|cidr6>\nLists all users on a given IP address or CIDR range.");
}
deregisterhook(HOOK_NICK_NEWNICK, &pn_hook_newuser);
deregisterhook(HOOK_NICK_LOSTNICK, &pn_hook_lostuser);
- deregisterhook(HOOK_NICK_MOVENODE, &pn_hook_nodemoveuser);
deregistercontrolcmd("nodeuserlist", &pn_cmd_nodeuserlist);
}
deletenickfromnode(np->ipnode, np);
}
-void pn_hook_nodemoveuser(int hook, void *arg) {
- nick *np = ((void **)arg)[0];
- patricia_node_t *oldnode = ((void **)arg)[1];
-
- deletenickfromnode(oldnode, np);
- addnicktonode(np->ipnode, np);
-}
-
int pn_cmd_nodeuserlist(void *source, int cargc, char **cargv) {
nick *np=(nick *)source;
struct irc_in_addr sin;
void pn_hook_newuser(int hook, void *arg);
void pn_hook_lostuser(int hook, void *arg);
-void pn_hook_nodemoveuser(int hook, void *arg);
void addnicktonode(patricia_node_t *node, nick *nick);
void deletenickfromnode(patricia_node_t *node, nick *nick);
} else {
setnextbytrust(sender, th->users);
th->users = sender;
- setipnodebits(sender, th->nodebits);
}
arg[0] = sender;
}
void th_update(trusthost *th) {
- nick *np;
-
- for(np=th->users;np;np=nextbytrust(np))
- setipnodebits(np, th->nodebits);
-
trustsdb->squery(trustsdb,
"UPDATE ? SET maxpernode = ?, nodebits = ? WHERE id = ?",
"Tuuu", "hosts", th->maxpernode, th->nodebits, th->id
long moving = (long)args[1];
trusthost *th = gettrusthost(np);
trustgroup *tg;
+ patricia_node_t *node;
+ int nodecount;
if(moving)
return;
tg = th->group;
- if(th->maxpernode && np->ipnode->usercount > th->maxpernode) {
+ node = refnode(iptree, &th->ip, th->nodebits);
+ nodecount = node->usercount;
+ derefnode(iptree, node);
+
+ if(th->maxpernode && nodecount > th->maxpernode) {
controlwall(NO_OPER, NL_TRUSTS, "Hard connection limit exceeded on IP: %s (group: %s) %d connected, %d max.", IPtostr(np->p_ipaddr), tg->name->content, np->ipnode->usercount, th->maxpernode);
return;
}