]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts/trusts_policy.c
1 #include "../core/hooks.h"
2 #include "../control/control.h"
7 static void policycheck(int hooknum
, void *arg
) {
10 long moving
= (long)args
[1];
11 trusthost
*th
= gettrusthost(np
);
18 if(np
->ipnode
->usercount
> 5)
19 controlwall(NO_OPER
, NL_TRUSTS
, "Hard limit exceeded on IP: %s (untrusted) %d connected, 5 max.", irc_in_addr_v4_to_int(&(np
->p_ipaddr
)), np
->ipnode
->usercount
);
25 * the purpose of this logic is to avoid spam like this:
26 * WARNING: tgX exceeded limit: 11 connected vs 10 max
27 * (goes back down to 10)
28 * WARNING: tgX exceeded limit: 11 connected vs 10 max
31 if(hooknum
== HOOK_TRUSTS_NEWNICK
) {
32 if(tg
->count
> tg
->maxusage
) {
33 if(tg
->count
> (long)tg
->exts
[countext
]) {
34 tg
->exts
[countext
] = (void *)(long)tg
->count
;
36 controlwall(NO_OPER
, NL_TRUSTS
, "Hard limit exceeded: '%s', %d connected, %d max.", tg
->name
->content
, tg
->count
, tg
->maxusage
);
40 if(tg
->count
< tg
->maxusage
)
41 tg
->exts
[countext
] = (void *)(long)tg
->count
;
46 countext
= registertgext("count");
50 registerhook(HOOK_TRUSTS_NEWNICK
, policycheck
);
51 registerhook(HOOK_TRUSTS_LOSTNICK
, policycheck
);
58 releasetgext(countext
);
60 deregisterhook(HOOK_TRUSTS_NEWNICK
, policycheck
);
61 deregisterhook(HOOK_TRUSTS_LOSTNICK
, policycheck
);