]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts2/trusts_handlers.c
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 (trusts_ignore_np(np
)) {
14 if(np
->ipnode
->exts
[tgh_ext
]) {
15 /* we have a new user on a trust group host */
16 tgh
= (trusthost_t
*)np
->ipnode
->exts
[tgh_ext
];
17 /* check if it has expired */
18 if(tgh
->expire
&& (tgh
->expire
<= getnettime())) {
19 trusthost_expire(tgh
);
23 if(tg
->expire
&& (tg
->expire
<= getnettime())) {
24 /* expire trust group */
25 trustgroup_expire(tg
);
32 /* recurse to see if a parent node is trusted */
33 parent
= np
->ipnode
->parent
;
36 if( parent
->exts
[tgh_ext
]) {
37 /* falls under parent trust */
38 tgh
= (trusthost_t
*)parent
->exts
[tgh_ext
];
39 if(tgh
->expire
&& (tgh
->expire
<= getnettime())) {
40 trusthost_expire(tgh
);
44 if(tg
->expire
&& (tg
->expire
<= getnettime())) {
45 /* expire trust group */
46 trustgroup_expire(tg
);
53 parent
= parent
->parent
;
58 /* we have a trusthost - check it */
60 if(((((int)(np
->ipnode
->usercount
))) > tg
->maxperip
) && tg
->maxperip
) {
61 /* user exceed ip trust limit - disconnect */
62 controlwall(NO_OPER
, NL_TRUSTS
, "TG %lu: Exceeding IP limit (%d / %d) for %s!%s@%s (%s)", tg
->id
, (((int)(np
->ipnode
->usercount
))), tg
->maxperip
, np
->nick
, np
->ident
, np
->host
->name
->content
, removeusers
== 1 ? "disconnected": "ignored");
63 //killuser(NULL, np, "USER: Exceeding IP Limit.");
65 if( tg
->maxclones
>0 ) {
66 if( (tg
->currenton
+ 1) > tg
->maxclones
) {
67 /* user exceeds trust group limit - disconnect */
68 //killuser(NULL, np, "USER: Exceeding Trustgroup Limit.");
69 controlwall(NO_OPER
, NL_TRUSTS
, "TG %lu: Exceeding trustgroup limit (%d / %d) for %s!%s@%s (%s)",tg
->id
, (tg
->currenton
+ 1), tg
->maxclones
, np
->nick
, np
->ident
, np
->host
->name
->content
, removeusers
== 1 ? "disconnected": "ignored");
72 if ( np
->ident
[0] == '~') {
74 if (tg
->enforceident
) {
75 controlwall(NO_OPER
, NL_TRUSTS
, "TG %lu: Ident Required for %s!%s@%s (%s)", tg
->id
, np
->nick
, np
->ident
, np
->host
->name
->content
, removeusers
== 1 ? "disconnected": "ignored");
76 //killuser(NULL, np, "USER: Ident Required From Your Host.");
77 /*TODO: add short gline here - ~*@%s - "IDENTD required from your host", "MissingIDENT" */
81 /*TODO: need to tidy out ident currenton */
82 increment_ident_count(np
, tg
);
84 /* Trust Checks Passed: OK - increment counters */
85 increment_trust_ipnode(np
->ipnode
);
87 /* set nick extension for user for future use */
88 np
->exts
[tgn_ext
] = tgh
;
92 /* non trusted user - OK */
96 void trusts_hook_lostuser(int hook
, void *arg
) {
97 nick
*np
= (nick
*)arg
;
98 trusthost_t
*tgh
= NULL
;
99 trustgroup_t
*tg
= NULL
;
100 patricia_node_t
*parent
;
103 Error("nodecount", ERR_ERROR
, "np was NULL");
106 Error("nodecount", ERR_ERROR
, "np->ipnode was NULL");
108 if(!np
->ipnode
->exts
) {
109 Error("nodecount", ERR_ERROR
, "np->ipnode->exts was NULL");
112 if (trusts_ignore_np(np
)) {
116 decrement_trust_ipnode(np
->ipnode
);
118 if(np
->ipnode
->exts
[tgh_ext
]) {
119 tgh
= (trusthost_t
*)np
->ipnode
->exts
[tgh_ext
];
121 parent
= np
->ipnode
->parent
;
124 if( parent
->exts
[tgh_ext
]) {
125 /* falls under parent trust */
126 tgh
= (trusthost_t
*)parent
->exts
[tgh_ext
];
129 parent
= parent
->parent
;
133 tg
= tgh
->trustgroup
;
134 if ( np
->ident
[0] != '~') {
135 decrement_ident_count(np
, tg
);
139 /* clear nick extension */
140 np
->exts
[tgn_ext
] = NULL
;