]>
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
) {
9 trusthost
*th
= gettrusthost(np
);
10 trustgroup
*tg
= th
->group
;
13 * the purpose of this logic is to avoid spam like this:
14 * WARNING: tgX exceeded limit: 11 connected vs 10 max
15 * (goes back down to 10)
16 * WARNING: tgX exceeded limit: 11 connected vs 10 max
19 if(hooknum
== HOOK_TRUSTS_NEWNICK
) {
20 if(tg
->count
> tg
->maxusage
) {
21 if(tg
->count
> (long)tg
->exts
[countext
]) {
22 tg
->exts
[countext
] = (void *)(long)tg
->count
;
24 controlwall(NO_OPER
, NL_TRUSTS
, "Hard limit exceeded: '%s', %d connected, %d max.", tg
->name
->content
, tg
->count
, tg
->maxusage
);
28 if(tg
->count
< tg
->maxusage
)
29 tg
->exts
[countext
] = (void *)(long)tg
->count
;
34 countext
= registertgext("count");
38 registerhook(HOOK_TRUSTS_NEWNICK
, policycheck
);
39 registerhook(HOOK_TRUSTS_LOSTNICK
, policycheck
);
46 releasetgext(countext
);
48 deregisterhook(HOOK_TRUSTS_NEWNICK
, policycheck
);
49 deregisterhook(HOOK_TRUSTS_LOSTNICK
, policycheck
);