]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts2/trusts_commands.c
1 #include "../core/schedule.h"
2 #include "../lib/irc_string.h"
3 #include "../localuser/localuserchannel.h"
4 #include "../control/control.h"
11 registerhook ( HOOK_TRUSTS_DBLOADED
, trusts_cmdinit
);
13 /* Now that the database is in a separate module it might be loaded already. */
15 trusts_cmdinit ( HOOK_TRUSTS_DBLOADED
, NULL
);
20 deregisterhook ( HOOK_TRUSTS_DBLOADED
, trusts_cmdinit
);
24 void trusts_cmdinit ( int hooknum
, void * arg
) {
25 registercontrolcmd ( "trustgroupadd" , 10 , 7 , trust_groupadd
);
26 registercontrolcmd ( "trustgroupmodify" , 10 , 4 , trust_groupmodify
);
27 registercontrolcmd ( "trustgroupdel" , 10 , 2 , trust_groupdel
);
29 registercontrolcmd ( "trustcomment" , 10 , 2 , trust_comment
);
31 registercontrolcmd ( "trustadd" , 10 , 3 , trust_add
);
32 registercontrolcmd ( "trustdel" , 10 , 2 , trust_del
);
34 registercontrolcmd ( "trustdenyadd" , 10 , 2 , trust_denyadd
);
35 registercontrolcmd ( "trustdenylist" , 10 , 2 , trust_denylist
);
36 registercontrolcmd ( "trustdenydel" , 10 , 2 , trust_denydel
);
38 registercontrolcmd ( "truststats" , 10 , 2 , trust_stats
);
39 registercontrolcmd ( "trustdump" , 10 , 2 , trust_dump
);
44 void trusts_cmdfini () {
45 deregistercontrolcmd ( "trustgroupadd" , trust_groupadd
);
46 deregistercontrolcmd ( "trustgroupmodify" , trust_groupmodify
);
47 deregistercontrolcmd ( "trustgroupdel" , trust_groupdel
);
49 deregistercontrolcmd ( "trustcomment" , trust_comment
);
51 deregistercontrolcmd ( "trustadd" , trust_add
);
52 deregistercontrolcmd ( "trustdel" , trust_del
);
54 deregistercontrolcmd ( "trustdenyadd" , trust_denyadd
);
55 deregistercontrolcmd ( "trustdenylist" , trust_denylist
);
56 deregistercontrolcmd ( "trustdenydel" , trust_denydel
);
58 deregistercontrolcmd ( "truststats" , trust_stats
);
59 deregistercontrolcmd ( "trustdump" , trust_dump
);
65 /* tgh - should this have a 'maxclones limit'? */
67 int trust_groupadd ( void * source
, int cargc
, char ** cargv
) {
68 nick
* sender
=( nick
*) source
;
70 unsigned long maxclones
;
71 unsigned short maxperip
;
72 unsigned long maxperident
;
75 unsigned long ownerid
;
79 controlreply ( sender
, "Usage: trustgroupadd howmany howlong maxperident maxperip enforceident type ownerid" );
83 maxclones
= strtoul ( cargv
[ 0 ], NULL
, 10 );
84 if ( maxclones
> 10000 ) {
85 /* we allow 0 for unlimited trusts, and only warn on this */
86 controlreply ( sender
, "WARNING: large maximum number of clients - %l u" , maxclones
);
88 expiry
= durationtolong ( cargv
[ 1 ]);
89 if ( expiry
> ( 365 * 86400 ) ) {
90 controlreply ( sender
, "ERROR: Invalid duration given - temporary trusts can not be longer then 1 year" );
93 ownerid
= strtoul ( cargv
[ 6 ], NULL
, 10 );
94 maxperip
= strtoul ( cargv
[ 3 ], NULL
, 10 );
96 controlreply ( sender
, "ERROR: MaxPerIP value should be less then 500 (if set)" );
99 maxperident
= strtoul ( cargv
[ 2 ], NULL
, 10 );
100 if ( maxperident
> 50 ) {
101 controlreply ( sender
, "ERROR: MaxPerIdent value should be less then 50 (if set)" );
104 if ((( cargv
[ 4 ][ 0 ]!= '0' ) && ( cargv
[ 4 ][ 0 ]!= '1' )) || ( cargv
[ 4 ][ 1 ]!= '\0' )) {
105 controlreply ( sender
, "ERROR: enforceident is a boolean setting, that means it can only be 0 or 1" );
108 enforceident
= cargv
[ 4 ][ 0 ] == '1' ;
110 if ( findtrustgroupbyownerid ( ownerid
) ) {
111 controlreply ( sender
, "ERROR: Q User ID %d already has a trustgroup" , ownerid
);
114 if ( ownerid
> 2147483646 ) {
115 controlreply ( sender
, "ERROR: Invalid Q User ID: %d " , ownerid
);
119 type
= strtoul ( cargv
[ 5 ], NULL
, 10 );
126 controlreply ( sender
, "Invalid Type ( %d )" , type
);
130 t
= createtrustgroup ( ++ trusts_lasttrustgroupid
, maxclones
, maxperident
, maxperip
, enforceident
, getnettime () + expiry
, ownerid
, type
);
133 controlreply ( sender
, "ERROR: An error occured adding trustgroup" );
137 trustsdb_addtrustgroup ( t
);
139 controlreply ( sender
, "Adding trustgroup with ID %l u" , t
-> id
);
140 controlreply ( sender
, "Connections: %d , Enforceident %d , Per ident: %d , Per IP %d " , maxclones
, enforceident
, maxperident
, maxperip
);
141 controlreply ( sender
, "Expires: %d , User ID: %d " , expiry
, ownerid
);
142 controlwall ( NO_OPER
, NL_TRUSTS
, "NewTrust: ID: %l u, Connections: %d , Enforceident %d , Per ident: %d , Per IP %d , Owner %d " , t
-> id
, maxclones
, enforceident
, maxperident
, maxperip
, ownerid
);
146 int trust_del ( void * source
, int cargc
, char ** cargv
) {
147 nick
* sender
=( nick
*) source
;
148 struct irc_in_addr sin
;
150 patricia_node_t
* node
;
154 controlreply ( sender
, "Syntax: trustdel IP[/mask]" );
158 if ( ipmask_parse ( cargv
[ 0 ], & sin
, & bits
) == 0 ) {
159 controlreply ( sender
, "ERROR: Invalid mask." );
163 node
= refnode ( iptree
, & sin
, bits
);
164 if (! node
-> exts
[ tgh_ext
]) {
165 controlreply ( sender
, "ERROR: That CIDR was not trusted." );
168 /*TODO: only allow a host to be removed if <X users? subnets? bah */
169 tg
= (( trusthost_t
*) node
-> exts
[ tgh_ext
])-> trustgroup
;
170 controlreply ( sender
, " %s removed from trustgroup # %l u" , cargv
[ 0 ], tg
-> id
);
171 controlwall ( NO_OPER
, NL_TRUSTS
, " %s removed from trustgroup # %l u" , cargv
[ 0 ], tg
-> id
);
172 trustsdb_deletetrusthost ( node
-> exts
[ tgh_ext
]);
173 trusthost_free ( node
-> exts
[ tgh_ext
]);
174 node
-> exts
[ tgh_ext
] = NULL
;
179 int trust_add ( void * source
, int cargc
, char ** cargv
) {
180 nick
* sender
=( nick
*) source
;
182 struct irc_in_addr sin
;
184 patricia_node_t
* node
, * inode
, * parent
;
189 controlreply ( sender
, "Syntax: trustadd <#groupid> IP[/mask] <duration>" );
193 if ( cargv
[ 0 ][ 0 ]== '#' ){
194 /* find group by id */
195 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
197 /* find group by id */
198 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
202 controlreply ( sender
, "ERROR: A trustgroup with that ID does not exist." );
207 controlreply ( sender
, "INTERNAL ERROR: Trustgroup has ID 0" );
211 if ( ipmask_parse ( cargv
[ 1 ], & sin
, & bits
) == 0 ) {
212 controlreply ( sender
, "ERROR: Invalid mask." );
216 if ( irc_in_addr_is_ipv4 (& sin
) ) {
217 if ( bits
> 128 || bits
< 112 ) {
218 controlreply ( sender
, "ERROR: Not a valid netmask (needs to be between 8 and 32)" );
223 controlreply ( sender
, "ERROR: Not a valid ipv6 netmask " );
229 expiry
= getnettime () + durationtolong ( cargv
[ 2 ]);
231 controlreply ( sender
, "ERROR: Invalid duration given" );
236 node
= refnode ( iptree
, & sin
, bits
);
237 if ( node
-> exts
[ tgh_ext
]) {
238 /* this mask is already trusted */
239 controlreply ( sender
, "ERROR: This mask is already trusted by trustgroup %l u." , (( trusthost_t
*) node
-> exts
[ tgh_ext
])-> trustgroup
-> id
);
243 /* check child status */
244 PATRICIA_WALK ( node
, inode
)
246 th
= inode
-> exts
[ tgh_ext
];
248 /* we have a child trustgroup */
249 /* Criteria 1: we can't add two hosts into the same group */
250 if ( th
-> trustgroup
== tg
) {
251 controlreply ( sender
, "ERROR: A child subnet is already in this trustgroup, remove that subnet first ( %s / %d )" , IPtostr ( inode
-> prefix
-> sin
), irc_bitlen (&( inode
-> prefix
-> sin
), inode
-> prefix
-> bitlen
));
258 /* check parents too */
259 parent
= node
-> parent
;
261 if ( parent
-> exts
[ tgh_ext
]) {
262 th
= parent
-> exts
[ tgh_ext
];
263 /* we have a parent trustgroup */
264 /* Criteria 1: we can't add two hosts into the same group */
265 if ( th
-> trustgroup
== tg
) {
266 controlreply ( sender
, "ERROR: A parent subnet is already in this trustgroup ( %s / %d )" , IPtostr ( parent
-> prefix
-> sin
), irc_bitlen (&( parent
-> prefix
-> sin
), parent
-> prefix
-> bitlen
));
269 /* even if we find 1 parent, we continue to the top */
271 parent
= parent
-> parent
;
274 th
= trusthostadd ( node
, tg
, expiry
);
276 controlreply ( sender
, "ERROR: Unable to add trusted host" );
279 trustsdb_addtrusthost ( th
);
280 controlreply ( sender
, "Added %s to trustgroup # %l u" , cargv
[ 1 ], tg
-> id
);
281 controlwall ( NO_OPER
, NL_TRUSTS
, "Added %s to trustgroup # %l u" , cargv
[ 1 ], tg
-> id
);
285 int trust_denyadd ( void * source
, int cargc
, char ** cargv
) {
286 nick
* sender
=( nick
*) source
;
288 controlreply ( sender
, "Not Implemented" );
292 int trust_dump ( void * source
, int cargc
, char ** cargv
) {
293 nick
* sender
=( nick
*) source
;
297 unsigned long startid
= 0 ;
298 long num
= 0 , count
= 0 , lines
= 0 ;
301 controlreply ( sender
, "Syntax: trustdump <start #id> <number>" );
302 controlreply ( sender
, "Dumps <number> trustgroups starting from <start #id>." );
303 controlreply ( sender
, "This allows to dump very large numbers of groups," );
304 controlreply ( sender
, "so use with care." );
307 strncpy ( tmps3
, cargv
[ 0 ], 20 );
309 num
= atoi ( cargv
[ 1 ]);
311 if ( tmps3
[ 0 ] != '#' ) {
312 controlreply ( sender
, "First parameter has to be a trust ID (prefixed with #)." );
316 startid
= strtoul (& tmps3
[ 1 ], NULL
, 10 );
318 controlreply ( sender
, "Cannot return fewer than 1 group." );
322 controlreply ( sender
, "Will not list more than 500 groups in one go." );
326 if ( startid
> trusts_lasttrustgroupid
) {
327 controlreply ( sender
, "Start ID cannot exceed maximum group ID (# %l d)." , trusts_lasttrustgroupid
);
332 g
= findtrustgroupbyid ( startid
);
334 } while (( g
== NULL
) && ( startid
<= ( trusts_lasttrustgroupid
+ 1 )));
336 controlreply ( sender
, "Failed to find nearest start group." );
340 while ( startid
<= ( trusts_lasttrustgroupid
+ 1 )) {
342 g
= findtrustgroupbyid ( startid
);
346 controlreply ( sender
, "G,# %l u, %l u, %l u, %d , %l u, %l u, %l u, %l u" ,
347 g
-> id
, g
-> currenton
, g
-> maxclones
, g
-> enforceident
, g
-> maxperident
,
348 g
-> maxusage
, g
-> expire
, g
-> lastused
);
353 int hash
= trusts_gettrusthostgroupidhash ( g
-> id
);
354 for ( thptr
= trusthostgroupidtable
[ hash
]; thptr
; thptr
= thptr
-> nextbygroupid
) {
355 if ( thptr
-> trustgroup
-> id
== g
-> id
) {
356 /* TODO: expire here - trusthost_free(thptr);*/
357 controlreply ( sender
, "H,# %l u, %s / %d , %l u, %l u, %l u" , g
-> id
,
358 IPtostr ((( patricia_node_t
*) thptr
-> node
)-> prefix
-> sin
),
359 irc_bitlen (&((( patricia_node_t
*) thptr
-> node
)-> prefix
-> sin
),(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
),
360 0 /*a->currentlyon*/ ,
371 g
= findtrustgroupbyid ( startid
);
374 controlreply ( sender
, "End of list, %l d groups and %l d lines returned." , count
, lines
);
378 int trust_denydel ( void * source
, int cargc
, char ** cargv
) {
379 nick
* sender
=( nick
*) source
;
381 controlreply ( sender
, "Not Implemented" );
385 int trust_denylist ( void * source
, int cargc
, char ** cargv
) {
386 nick
* sender
=( nick
*) source
;
388 controlreply ( sender
, "Not Implemented" );
392 int trust_groupmodify ( void * source
, int cargc
, char ** cargv
) {
393 nick
* sender
=( nick
*) source
;
394 unsigned long oldvalue
, newvalue
;
399 if ( cargc
< 3 || cargc
== 4 ) {
400 controlreply ( sender
, "Syntax: trustgroupmodify <#groupid> <what> [+|-|=]number" );
401 controlreply ( sender
, " +20 means add 20, =20 replaces current value, -20 means subtract" );
402 controlreply ( sender
, " what: maxclones, maxperident, maxperip, expire, enforceident, ownerid" );
406 if ( cargv
[ 0 ][ 0 ]== '#' ){
407 /* find group by id */
408 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
410 /* find group by id */
411 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
415 controlreply ( sender
, "ERROR: A trustgroup with that ID does not exist." );
420 controlreply ( sender
, "INTERNAL ERROR: Trustgroup has ID 0" );
424 switch ( cargv
[ 2 ][ 0 ] ) {
431 controlreply ( sender
, "ERROR: invalid modifier specified (values values are +,-,=)" );
434 newvalue
= strtoul (& cargv
[ 2 ][ 1 ], NULL
, 10 );
436 if ( ircd_strcmp ( cargv
[ 1 ], "maxclones" )== 0 ) {
437 oldvalue
= tg
-> maxclones
;
440 newvalue
= oldvalue
+ newvalue
;
443 if ( newvalue
> oldvalue
) {
444 controlreply ( sender
, "ERROR: maxclones cannot be less than 0" );
447 newvalue
= oldvalue
- newvalue
;
449 controlreply ( sender
, "ERROR: maxclones limit would be 0 - unlimited maxclones can only be set with '='" );
455 if ( newvalue
> 1000000 ) {
456 controlreply ( sender
, "ERROR: large maximum number of clients - %l u" , newvalue
);
459 if ( newvalue
> 10000 ) {
460 controlreply ( sender
, "WARNING: large maximum number of clients - %l u" , newvalue
);
463 tg
-> maxclones
= newvalue
;
464 } else if ( ircd_strcmp ( cargv
[ 1 ], "maxperident" )== 0 ) {
465 oldvalue
= tg
-> maxperident
;
468 newvalue
= oldvalue
+ newvalue
;
471 if ( newvalue
> oldvalue
) {
472 controlreply ( sender
, "ERROR: maxperident cannot be less than 0" );
475 newvalue
= oldvalue
- newvalue
;
477 controlreply ( sender
, "ERROR: maxperident limit would be 0 - unlimited maxclones can only be set with '='" );
484 controlreply ( sender
, "ERROR: MaxPerIdent value should be less then 50 (if set)" );
487 tg
-> maxperident
= newvalue
;
488 } else if ( ircd_strcmp ( cargv
[ 1 ], "maxperip" )== 0 ) {
489 oldvalue
= tg
-> maxperip
;
492 newvalue
= oldvalue
+ newvalue
;
495 if ( newvalue
> oldvalue
) {
496 controlreply ( sender
, "ERROR: maxperip cannot be less than 0" );
499 newvalue
= oldvalue
- newvalue
;
501 controlreply ( sender
, "ERROR: maxperip limit would be 0 - unlimited maxclones can only be set with '='" );
507 if ( newvalue
> 500 ) {
508 controlreply ( sender
, "ERROR: MaxPerIP value should be less then 500 (if set)" );
511 tg
-> maxperip
= newvalue
;
512 } else if ( ircd_strcmp ( cargv
[ 1 ], "expire" )== 0 ) {
513 oldvalue
= tg
-> expire
;
514 expiry
= durationtolong (& cargv
[ 2 ][ 1 ]);
516 if ( expiry
> ( 365 * 86400 ) ) {
517 controlreply ( sender
, "ERROR: Invalid duration given - temporary trusts can not be longer then 1 year" );
523 newvalue
= oldvalue
+ expiry
;
526 newvalue
= oldvalue
- expiry
;
527 if ( newvalue
< getnettime () ) {
528 controlreply ( sender
, "ERROR: Can't set expiry before current nettime - use trustgroupdel to delete trust groups" );
534 newvalue
= getnettime () + expiry
;
538 tg
-> expire
= newvalue
;
539 } else if ( ircd_strcmp ( cargv
[ 1 ], "enforceident" )== 0 ) {
540 oldvalue
= tg
-> enforceident
;
541 if ( ( newvalue
!= 0 && newvalue
!= 1 ) || * mod
!= '=' ) {
542 controlreply ( sender
, "ERROR: enforceident is a boolean setting, that means it can only be 0 or 1, and can only be set by '='" );
545 tg
-> enforceident
= newvalue
;
546 } else if ( ircd_strcmp ( cargv
[ 1 ], "ownerid" )== 0 ) {
547 oldvalue
= tg
-> ownerid
;
549 controlreply ( sender
, "ERROR: Q user ID can only be set by '='" );
552 if ( findtrustgroupbyownerid ( newvalue
) ) {
553 controlreply ( sender
, "ERROR: Q User ID %d already has a trustgroup" , newvalue
);
557 if ( newvalue
> 2147483646 ) {
558 controlreply ( sender
, "ERROR: Invalid Q User ID: %d " , newvalue
);
562 tg
-> ownerid
= newvalue
;
564 controlreply ( sender
, "Modification: %s changed to %l u from %l u for trustgroup %l u" , cargv
[ 1 ], newvalue
, oldvalue
, tg
-> id
);
565 controlwall ( NO_OPER
, NL_TRUSTS
, "Modification: %s changed to %l u from %l u for trustgroup %l u" , cargv
[ 1 ], newvalue
, oldvalue
, tg
-> id
);
567 trustsdb_updatetrustgroup ( tg
);
571 int trust_groupdel ( void * source
, int cargc
, char ** cargv
) {
572 nick
* sender
=( nick
*) source
;
573 trusthost_t
* thptr
, * nthptr
;
575 patricia_node_t
* node
;
578 controlreply ( sender
, "Syntax: trustgroupdel <#id|id>" );
582 if ( cargv
[ 0 ][ 0 ]== '#' ){
583 /* find group by id */
584 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
586 /* find group by id */
587 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
591 controlreply ( sender
, "ERROR: A trustgroup with that ID does not exist." );
596 controlreply ( sender
, "INTERNAL ERROR: Trustgroup has ID 0" );
600 /* we have a trustgroup to remove */
601 int hash
= trusts_gettrusthostgroupidhash ( tg
-> id
);
602 for ( thptr
= trusthostgroupidtable
[ hash
]; thptr
; thptr
= nthptr
) {
603 nthptr
= thptr
-> nextbygroupid
;
604 if ( thptr
-> trustgroup
== tg
) {
606 controlwall ( NO_OPER
, NL_TRUSTS
, " %s / %d removed from trustgroup # %l u" , IPtostr ( thptr
-> node
-> prefix
-> sin
), irc_bitlen (&( thptr
-> node
-> prefix
-> sin
), thptr
-> node
-> prefix
-> bitlen
), tg
-> id
);
607 controlreply ( sender
, " %s / %d removed from trustgroup # %l u" , IPtostr ( thptr
-> node
-> prefix
-> sin
), irc_bitlen (&( thptr
-> node
-> prefix
-> sin
), thptr
-> node
-> prefix
-> bitlen
), tg
-> id
);
608 trustsdb_deletetrusthost ( thptr
);
609 trusthost_free ( thptr
);
610 node
-> exts
[ tgh_ext
] = NULL
;
613 controlwall ( NO_OPER
, NL_TRUSTS
, "removed trustgroup # %l u" , tg
-> id
);
614 controlreply ( sender
, "removed trustgroup # %l u" , tg
-> id
);
615 trustsdb_deletetrustgroup ( tg
);
621 int trust_stats ( void * source
, int cargc
, char ** cargv
) {
622 nick
* sender
=( nick
*) source
;
623 trustgroup_t
* tg
; trusthost_t
* thptr
; int i
;
624 unsigned long thcount
= 0 , ucount
= 0 , mcount
= 0 , tgcount
= 0 ;
625 unsigned long hentries
= 0 ;
626 unsigned long netcount4
[ 33 ];
627 unsigned long netucount4
[ 33 ];
628 unsigned long netmcount4
[ 33 ];
629 unsigned long netcount6
[ 129 ];
630 unsigned long netucount6
[ 129 ];
631 unsigned long netmcount6
[ 129 ];
634 int maxthmask6
= 128 ;
636 for ( i
= 0 ; i
< 33 ; i
++) {
642 for ( i
= 0 ; i
< 129 ; i
++) {
648 for ( i
= 0 ; i
< TRUSTS_HASH_GROUPSIZE
; i
++ ) {
649 for ( tg
= trustgroupidtable
[ i
]; tg
; tg
= tg
-> nextbyid
) {
655 for ( i
= 0 ; i
< TRUSTS_HASH_HOSTSIZE
; i
++ ) {
656 for ( thptr
= trusthostidtable
[ i
]; thptr
; thptr
= thptr
-> nextbyid
) {
660 ucount
+= thptr
-> node
-> usercount
;
661 mcount
+= thptr
-> maxused
;
662 if ( irc_in_addr_is_ipv4 (&(( patricia_node_t
*) thptr
-> node
)-> prefix
-> sin
)) {
663 netcount4
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ]++;
664 netucount4
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ]+= thptr
-> node
-> usercount
;
665 netmcount4
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ]+= thptr
-> maxused
;
666 if ( ((( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ) < maxthmask4
) {
667 maxthmask4
= ((( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 );
670 netcount6
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
]++;
671 netucount6
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
]+= thptr
-> node
-> usercount
;
672 netmcount6
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
]+= thptr
-> maxused
;
673 if ( (( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
< maxthmask6
) {
674 maxthmask6
= (( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
;
679 controlreply ( sender
, "Online trust users: %l u" , ucount
);
680 controlreply ( sender
, "Maximum online users: %l u" , mcount
);
681 controlreply ( sender
, "Trust groups: %l u" , tgcount
);
682 controlreply ( sender
, "Maximum group ID: # %l u" , trusts_lasttrustgroupid
);
683 controlreply ( sender
, "Trusted hosts/nets: %l u" , thcount
);
684 controlreply ( sender
, "Largest subnet (v4): / %d " , maxthmask4
);
685 controlreply ( sender
, "Largest subnet (v6): / %d " , maxthmask6
);
686 controlreply ( sender
, "IPv4 Subnets:" );
687 for ( i
= 0 ; i
< 32 ; i
++) {
688 if ( netcount4
[ i
]== 0 ) continue ;
689 controlreply ( sender
, "|-*/ %d (Netcount: %l u Cur: %l u Max: %l u)" , i
, netcount4
[ i
], netucount4
[ i
], netmcount4
[ i
]);
691 controlreply ( sender
, "`-*/32 (Netcount: %l u Cur: %l u Max: %l u)" , netcount4
[ 32 ], netucount4
[ 32 ], netmcount4
[ 32 ]);
692 controlreply ( sender
, "IPv6 Subnets:" );
693 for ( i
= 0 ; i
< 128 ; i
++) {
694 if ( netcount6
[ i
]== 0 ) continue ;
695 controlreply ( sender
, "|-*/ %d (Netcount: %l u Cur: %l u Max: %l u)" , i
, netcount6
[ i
], netucount6
[ i
], netmcount6
[ i
]);
697 controlreply ( sender
, "`-*/128 (Netcount: %l u Cur: %l u Max: %l u)" , netcount6
[ 128 ], netucount6
[ 128 ], netmcount6
[ 128 ]);
703 int trust_comment ( void * source
, int cargc
, char ** cargv
) {
704 nick
* sender
=( nick
*) source
;
708 controlreply ( sender
, "Syntax: trustcomment <#groupid> <comment>" );
712 if ( cargv
[ 0 ][ 0 ]== '#' ){
713 /* find group by id */
714 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
716 /* find group by id */
717 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
721 controlreply ( sender
, "A trustgroup with that ID does not exist." );
726 controlreply ( sender
, "Internal error: Trustgroup has ID 0" );
730 trustsdb_logmessage ( tg
, 0 , 1 , cargv
[ 1 ]);
732 controlreply ( sender
, "Comment: %s for trustgroup %l u" , cargv
[ 1 ], tg
-> id
);
733 controlwall ( NO_OPER
, NL_TRUSTS
, "Comment: %s for trustgroup %l u" , cargv
[ 1 ], tg
-> id
);