]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts2/trusts_handlers.c
f7003ce02dd687676d12d514da119cd1977e3ef1
3 void trusts_hook_newuser(int hook
, void *arg
) {
4 /*TODO: add subnet clone warnings somewhere */
5 nick
*np
= (nick
*)arg
;
6 trusthost_t
*tgh
= NULL
;
7 trustgroup_t
*tg
= NULL
;
8 patricia_node_t
*parent
;
10 if(np
->ipnode
->exts
[tgh_ext
]) {
11 /* we have a new user on a trust group host */
12 tgh
= (trusthost_t
*)np
->ipnode
->exts
[tgh_ext
];
13 /* check if it has expired */
14 if(tgh
->expire
&& (tgh
->expire
<= getnettime())) {
15 trusthost_expire(tgh
);
19 if(tg
->expire
&& (tg
->expire
<= getnettime())) {
20 /* expire trust group */
21 trustgroup_expire(tg
);
28 /* recurse to see if a parent node is trusted */
29 parent
= np
->ipnode
->parent
;
32 if( parent
->exts
[tgh_ext
]) {
33 /* falls under parent trust */
34 tgh
= (trusthost_t
*)parent
->exts
[tgh_ext
];
35 if(tgh
->expire
&& (tgh
->expire
<= getnettime())) {
36 trusthost_expire(tgh
);
40 if(tg
->expire
&& (tg
->expire
<= getnettime())) {
41 /* expire trust group */
42 trustgroup_expire(tg
);
49 parent
= parent
->parent
;
54 /* we have a trusthost - check it */
56 if(((((int)(np
->ipnode
->usercount
))) > tg
->maxperip
) && tg
->maxperip
) {
57 /* user exceed ip trust limit - disconnect */
58 controlwall(NO_OPER
, NL_TRUSTS
, "KILL TG %lu: Exceeding IP limit (%d / %d) for %s!%s@%s", tg
->id
, (((int)(np
->ipnode
->usercount
))), tg
->maxperip
, np
->nick
, np
->ident
, np
->host
->name
->content
);
59 //killuser(NULL, np, "USER: Exceeding IP Limit.");
61 if( tg
->maxclones
>0 ) {
62 if( (tg
->currenton
+ 1) > tg
->maxclones
) {
63 /* user exceeds trust group limit - disconnect */
64 //killuser(NULL, np, "USER: Exceeding Trustgroup Limit.");
65 controlwall(NO_OPER
, NL_TRUSTS
, "KILL TG %lu: Excedding trustgroup limit (%d / %d) for %s!%s@%s",tg
->id
, (tg
->currenton
+ 1), tg
->maxclones
, np
->nick
, np
->ident
, np
->host
->name
->content
);
68 if ( np
->ident
[0] == '~') {
70 if (tg
->enforceident
) {
71 controlwall(NO_OPER
, NL_TRUSTS
, "KILL TG %lu: Ident Required for %s!%s@%s", tg
->id
, np
->nick
, np
->ident
, np
->host
->name
->content
);
72 //killuser(NULL, np, "USER: Ident Required From Your Host.");
73 /*TODO: add short gline here - ~*@%s - "IDENTD required from your host", "MissingIDENT" */
77 /*TODO: need to tidy out ident currenton */
78 increment_ident_count(np
, tg
);
80 /* Trust Checks Passed: OK - increment counters */
81 increment_trust_ipnode(np
->ipnode
);
84 /* non trusted user - OK */
88 void trusts_hook_lostuser(int hook
, void *arg
) {
89 nick
*np
= (nick
*)arg
;
90 trusthost_t
*tgh
= NULL
;
91 trustgroup_t
*tg
= NULL
;
92 patricia_node_t
*parent
;
95 Error("nodecount", ERR_ERROR
, "np was NULL");
98 Error("nodecount", ERR_ERROR
, "np->ipnode was NULL");
100 if(!np
->ipnode
->exts
) {
101 Error("nodecount", ERR_ERROR
, "np->ipnode->exts was NULL");
104 decrement_trust_ipnode(np
->ipnode
);
106 if(np
->ipnode
->exts
[tgh_ext
]) {
107 tgh
= (trusthost_t
*)np
->ipnode
->exts
[tgh_ext
];
109 parent
= np
->ipnode
->parent
;
112 if( parent
->exts
[tgh_ext
]) {
113 /* falls under parent trust */
114 tgh
= (trusthost_t
*)parent
->exts
[tgh_ext
];
117 parent
= parent
->parent
;
121 tg
= tgh
->trustgroup
;
122 if ( np
->ident
[0] != '~') {
123 decrement_ident_count(np
, tg
);