]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts/trusts_policy.c
1 #include "../core/hooks.h"
2 #include "../control/control.h"
3 #include "../lib/irc_string.h"
8 static void policycheck(int hooknum
, void *arg
) {
11 long moving
= (long)args
[1];
12 trusthost
*th
= gettrusthost(np
);
14 patricia_node_t
*node
;
25 node
= refnode(iptree
, &th
->ip
, th
->nodebits
);
26 nodecount
= node
->usercount
;
27 derefnode(iptree
, node
);
29 if(th
->maxpernode
&& nodecount
> th
->maxpernode
) {
30 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
);
35 * the purpose of this logic is to avoid spam like this:
36 * WARNING: tgX exceeded limit: 11 connected vs 10 max
37 * (goes back down to 10)
38 * WARNING: tgX exceeded limit: 11 connected vs 10 max
41 if(hooknum
== HOOK_TRUSTS_NEWNICK
) {
42 if(tg
->trustedfor
&& tg
->count
> tg
->trustedfor
) {
44 if(tg->count > (long)tg->exts[countext]) {
46 tg->exts[countext] = (void *)(long)tg->count;
48 controlwall(NO_OPER
, NL_TRUSTS
, "Hard connection limit exceeded: '%s', %d connected, %d max.", tg
->name
->content
, tg
->count
, tg
->trustedfor
);
53 if((tg
->mode
== 1) && (np
->ident
[0] == '~'))
54 controlwall(NO_OPER
, NL_TRUSTS
, "Ident required: '%s' %s!%s@%s.", tg
->name
->content
, np
->nick
, np
->ident
, np
->host
->name
->content
);
56 if(tg
->maxperident
> 0) {
61 for(th2
=tg
->hosts
;th2
;th2
=th2
->next
) {
62 for(tnp
=th2
->users
;tnp
;tnp
=nextbytrust(tnp
)) {
63 if(!ircd_strcmp(tnp
->ident
, np
->ident
))
68 if(identcount
> tg
->maxperident
)
69 controlwall(NO_OPER
, NL_TRUSTS
, "Hard ident limit exceeded: '%s' %s!%s@%s, %d connected, %d max.", tg
->name
->content
, np
->nick
, np
->ident
, np
->host
->name
->content
, identcount
, tg
->maxperident
);
72 if(tg
->count
< tg
->maxusage
)
73 tg
->exts
[countext
] = (void *)(long)tg
->count
;
78 countext
= registertgext("count");
82 registerhook(HOOK_TRUSTS_NEWNICK
, policycheck
);
83 registerhook(HOOK_TRUSTS_LOSTNICK
, policycheck
);
90 releasetgext(countext
);
92 deregisterhook(HOOK_TRUSTS_NEWNICK
, policycheck
);
93 deregisterhook(HOOK_TRUSTS_LOSTNICK
, policycheck
);