]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts2/trustscmd.c
1 #include "../core/schedule.h"
2 #include "../lib/irc_string.h"
3 #include "../localuser/localuserchannel.h"
4 #include "../control/control.h"
8 void trusts_cmdinit () {
9 registercontrolcmd ( "trustgroupadd" , 10 , 7 , trust_groupadd
);
10 registercontrolcmd ( "trustgroupmodify" , 10 , 4 , trust_groupmodify
);
11 registercontrolcmd ( "trustgroupdel" , 10 , 2 , trust_groupdel
);
13 registercontrolcmd ( "trustcomment" , 10 , 2 , trust_comment
);
15 registercontrolcmd ( "trustadd" , 10 , 3 , trust_add
);
16 registercontrolcmd ( "trustdel" , 10 , 2 , trust_del
);
18 registercontrolcmd ( "trustdenyadd" , 10 , 2 , trust_denyadd
);
19 registercontrolcmd ( "trustdenylist" , 10 , 2 , trust_denylist
);
20 registercontrolcmd ( "trustdenydel" , 10 , 2 , trust_denydel
);
22 registercontrolcmd ( "truststats" , 10 , 2 , trust_stats
);
23 registercontrolcmd ( "trustdump" , 10 , 2 , trust_dump
);
26 void trusts_cmdfini () {
27 deregistercontrolcmd ( "trustgroupadd" , trust_groupadd
);
28 deregistercontrolcmd ( "trustgroupmodify" , trust_groupmodify
);
29 deregistercontrolcmd ( "trustgroupdel" , trust_groupdel
);
31 deregistercontrolcmd ( "trustcomment" , trust_comment
);
33 deregistercontrolcmd ( "trustadd" , trust_add
);
34 deregistercontrolcmd ( "trustdel" , trust_del
);
36 deregistercontrolcmd ( "trustdenyadd" , trust_denyadd
);
37 deregistercontrolcmd ( "trustdenylist" , trust_denylist
);
38 deregistercontrolcmd ( "trustdenydel" , trust_denydel
);
40 deregistercontrolcmd ( "truststats" , trust_stats
);
41 deregistercontrolcmd ( "trustdump" , trust_dump
);
45 /* tgh - should this have a 'maxclones limit'? */
47 int trust_groupadd ( void * source
, int cargc
, char ** cargv
) {
48 nick
* sender
=( nick
*) source
;
50 unsigned long maxclones
;
51 unsigned short maxperip
;
52 unsigned long maxperident
;
55 unsigned long ownerid
;
59 controlreply ( sender
, "Usage: trustgroupadd howmany howlong maxperident maxperip enforceident type ownerid" );
63 maxclones
= strtoul ( cargv
[ 0 ], NULL
, 10 );
64 if ( maxclones
> 10000 ) {
65 /* we allow 0 for unlimited trusts, and only warn on this */
66 controlreply ( sender
, "WARNING: large maximum number of clients - %l u" , maxclones
);
68 expiry
= durationtolong ( cargv
[ 1 ]);
69 if ( expiry
> ( 365 * 86400 ) ) {
70 controlreply ( sender
, "ERROR: Invalid duration given - temporary trusts can not be longer then 1 year" );
73 ownerid
= strtoul ( cargv
[ 6 ], NULL
, 10 );
74 maxperip
= strtoul ( cargv
[ 3 ], NULL
, 10 );
76 controlreply ( sender
, "ERROR: MaxPerIP value should be less then 500 (if set)" );
79 maxperident
= strtoul ( cargv
[ 2 ], NULL
, 10 );
80 if ( maxperident
> 50 ) {
81 controlreply ( sender
, "ERROR: MaxPerIdent value should be less then 50 (if set)" );
84 if ((( cargv
[ 4 ][ 0 ]!= '0' ) && ( cargv
[ 4 ][ 0 ]!= '1' )) || ( cargv
[ 4 ][ 1 ]!= '\0' )) {
85 controlreply ( sender
, "ERROR: enforceident is a boolean setting, that means it can only be 0 or 1" );
88 enforceident
= cargv
[ 4 ][ 0 ] == '1' ;
90 if ( findtrustgroupbyownerid ( ownerid
) ) {
91 controlreply ( sender
, "ERROR: Q User ID %d already has a trustgroup" , ownerid
);
94 if ( ownerid
> 2147483646 ) {
95 controlreply ( sender
, "ERROR: Invalid Q User ID: %d " , ownerid
);
99 type
= strtoul ( cargv
[ 5 ], NULL
, 10 );
106 controlreply ( sender
, "Invalid Type ( %d )" , type
);
110 t
= createtrustgroup ( ++ trusts_lasttrustgroupid
, maxclones
, maxperident
, maxperip
, enforceident
, getnettime () + expiry
, ownerid
, type
);
113 controlreply ( sender
, "ERROR: An error occured adding trustgroup" );
117 trustsdb_addtrustgroup ( t
);
119 controlreply ( sender
, "Adding trustgroup with ID %l u" , t
-> id
);
120 controlreply ( sender
, "Connections: %d , Enforceident %d , Per ident: %d , Per IP %d " , maxclones
, enforceident
, maxperident
, maxperip
);
121 controlreply ( sender
, "Expires: %d , User ID: %d " , expiry
, ownerid
);
122 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
);
126 int trust_del ( void * source
, int cargc
, char ** cargv
) {
127 nick
* sender
=( nick
*) source
;
128 struct irc_in_addr sin
;
130 patricia_node_t
* node
;
134 controlreply ( sender
, "Syntax: trustdel IP[/mask]" );
138 if ( ipmask_parse ( cargv
[ 0 ], & sin
, & bits
) == 0 ) {
139 controlreply ( sender
, "ERROR: Invalid mask." );
143 node
= refnode ( iptree
, & sin
, bits
);
144 if (! node
-> exts
[ tgh_ext
]) {
145 controlreply ( sender
, "ERROR: That CIDR was not trusted." );
148 /*TODO: only allow a host to be removed if <X users? subnets? bah */
149 tg
= (( trusthost_t
*) node
-> exts
[ tgh_ext
])-> trustgroup
;
150 controlreply ( sender
, " %s removed from trustgroup # %l u" , cargv
[ 0 ], tg
-> id
);
151 controlwall ( NO_OPER
, NL_TRUSTS
, " %s removed from trustgroup # %l u" , cargv
[ 0 ], tg
-> id
);
152 trustsdb_deletetrusthost ( node
-> exts
[ tgh_ext
]);
153 trusthost_free ( node
-> exts
[ tgh_ext
]);
154 node
-> exts
[ tgh_ext
] = NULL
;
159 int trust_add ( void * source
, int cargc
, char ** cargv
) {
160 nick
* sender
=( nick
*) source
;
162 struct irc_in_addr sin
;
164 patricia_node_t
* node
, * inode
, * parent
;
169 controlreply ( sender
, "Syntax: trustadd <#groupid> IP[/mask] <duration>" );
173 if ( cargv
[ 0 ][ 0 ]== '#' ){
174 /* find group by id */
175 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
177 /* find group by id */
178 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
182 controlreply ( sender
, "ERROR: A trustgroup with that ID does not exist." );
187 controlreply ( sender
, "INTERNAL ERROR: Trustgroup has ID 0" );
191 if ( ipmask_parse ( cargv
[ 1 ], & sin
, & bits
) == 0 ) {
192 controlreply ( sender
, "ERROR: Invalid mask." );
196 if ( irc_in_addr_is_ipv4 (& sin
) ) {
197 if ( bits
> 128 || bits
< 112 ) {
198 controlreply ( sender
, "ERROR: Not a valid netmask (needs to be between 8 and 32)" );
203 controlreply ( sender
, "ERROR: Not a valid ipv6 netmask " );
209 expiry
= getnettime () + durationtolong ( cargv
[ 2 ]);
211 controlreply ( sender
, "ERROR: Invalid duration given" );
216 node
= refnode ( iptree
, & sin
, bits
);
217 if ( node
-> exts
[ tgh_ext
]) {
218 /* this mask is already trusted */
219 controlreply ( sender
, "ERROR: This mask is already trusted by trustgroup %l u." , (( trusthost_t
*) node
-> exts
[ tgh_ext
])-> trustgroup
-> id
);
223 /* check child status */
224 PATRICIA_WALK ( node
, inode
)
226 th
= inode
-> exts
[ tgh_ext
];
228 /* we have a child trustgroup */
229 /* Criteria 1: we can't add two hosts into the same group */
230 if ( th
-> trustgroup
== tg
) {
231 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
));
238 /* check parents too */
239 parent
= node
-> parent
;
241 if ( parent
-> exts
[ tgh_ext
]) {
242 th
= parent
-> exts
[ tgh_ext
];
243 /* we have a parent trustgroup */
244 /* Criteria 1: we can't add two hosts into the same group */
245 if ( th
-> trustgroup
== tg
) {
246 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
));
249 /* even if we find 1 parent, we continue to the top */
251 parent
= parent
-> parent
;
254 th
= trusthostadd ( node
, tg
, expiry
);
256 controlreply ( sender
, "ERROR: Unable to add trusted host" );
259 trustsdb_addtrusthost ( th
);
260 controlreply ( sender
, "Added %s to trustgroup # %l u" , cargv
[ 1 ], tg
-> id
);
261 controlwall ( NO_OPER
, NL_TRUSTS
, "Added %s to trustgroup # %l u" , cargv
[ 1 ], tg
-> id
);
265 int trust_denyadd ( void * source
, int cargc
, char ** cargv
) {
266 nick
* sender
=( nick
*) source
;
268 controlreply ( sender
, "Not Implemented" );
272 int trust_dump ( void * source
, int cargc
, char ** cargv
) {
273 nick
* sender
=( nick
*) source
;
277 unsigned long startid
= 0 ;
278 long num
= 0 , count
= 0 , lines
= 0 ;
281 controlreply ( sender
, "Syntax: trustdump <start #id> <number>" );
282 controlreply ( sender
, "Dumps <number> trustgroups starting from <start #id>." );
283 controlreply ( sender
, "This allows to dump very large numbers of groups," );
284 controlreply ( sender
, "so use with care." );
287 strncpy ( tmps3
, cargv
[ 0 ], 20 );
289 num
= atoi ( cargv
[ 1 ]);
291 if ( tmps3
[ 0 ] != '#' ) {
292 controlreply ( sender
, "First parameter has to be a trust ID (prefixed with #)." );
296 startid
= strtoul (& tmps3
[ 1 ], NULL
, 10 );
298 controlreply ( sender
, "Cannot return fewer than 1 group." );
302 controlreply ( sender
, "Will not list more than 500 groups in one go." );
306 if ( startid
> trusts_lasttrustgroupid
) {
307 controlreply ( sender
, "Start ID cannot exceed maximum group ID (# %l d)." , trusts_lasttrustgroupid
);
312 g
= findtrustgroupbyid ( startid
);
314 } while (( g
== NULL
) && ( startid
<= ( trusts_lasttrustgroupid
+ 1 )));
316 controlreply ( sender
, "Failed to find nearest start group." );
320 while ( startid
<= ( trusts_lasttrustgroupid
+ 1 )) {
322 g
= findtrustgroupbyid ( startid
);
326 controlreply ( sender
, "G,# %l u, %l u, %l u, %d , %l u, %l u, %l u, %l u" ,
327 g
-> id
, g
-> currenton
, g
-> maxclones
, g
-> enforceident
, g
-> maxperident
,
328 g
-> maxusage
, g
-> expire
, g
-> lastused
);
333 int hash
= trusts_gettrusthostgroupidhash ( g
-> id
);
334 for ( thptr
= trusthostgroupidtable
[ hash
]; thptr
; thptr
= thptr
-> nextbygroupid
) {
335 if ( thptr
-> trustgroup
-> id
== g
-> id
) {
336 /* TODO: expire here - trusthost_free(thptr);*/
337 controlreply ( sender
, "H,# %l u, %s / %d , %l u, %l u, %l u" , g
-> id
,
338 IPtostr ((( patricia_node_t
*) thptr
-> node
)-> prefix
-> sin
),
339 irc_bitlen (&((( patricia_node_t
*) thptr
-> node
)-> prefix
-> sin
),(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
),
340 0 /*a->currentlyon*/ ,
351 g
= findtrustgroupbyid ( startid
);
354 controlreply ( sender
, "End of list, %l d groups and %l d lines returned." , count
, lines
);
358 int trust_denydel ( void * source
, int cargc
, char ** cargv
) {
359 nick
* sender
=( nick
*) source
;
361 controlreply ( sender
, "Not Implemented" );
365 int trust_denylist ( void * source
, int cargc
, char ** cargv
) {
366 nick
* sender
=( nick
*) source
;
368 controlreply ( sender
, "Not Implemented" );
372 int trust_groupmodify ( void * source
, int cargc
, char ** cargv
) {
373 nick
* sender
=( nick
*) source
;
374 unsigned long oldvalue
, newvalue
;
379 if ( cargc
< 3 || cargc
== 4 ) {
380 controlreply ( sender
, "Syntax: trustgroupmodify <#groupid> <what> [+|-|=]number" );
381 controlreply ( sender
, " +20 means add 20, =20 replaces current value, -20 means subtract" );
382 controlreply ( sender
, " what: maxclones, maxperident, maxperip, expire, enforceident, ownerid" );
386 if ( cargv
[ 0 ][ 0 ]== '#' ){
387 /* find group by id */
388 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
390 /* find group by id */
391 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
395 controlreply ( sender
, "ERROR: A trustgroup with that ID does not exist." );
400 controlreply ( sender
, "INTERNAL ERROR: Trustgroup has ID 0" );
404 switch ( cargv
[ 2 ][ 0 ] ) {
411 controlreply ( sender
, "ERROR: invalid modifier specified (values values are +,-,=)" );
414 newvalue
= strtoul (& cargv
[ 2 ][ 1 ], NULL
, 10 );
416 if ( ircd_strcmp ( cargv
[ 1 ], "maxclones" )== 0 ) {
417 oldvalue
= tg
-> maxclones
;
420 newvalue
= oldvalue
+ newvalue
;
423 if ( newvalue
> oldvalue
) {
424 controlreply ( sender
, "ERROR: maxclones cannot be less than 0" );
427 newvalue
= oldvalue
- newvalue
;
429 controlreply ( sender
, "ERROR: maxclones limit would be 0 - unlimited maxclones can only be set with '='" );
435 if ( newvalue
> 1000000 ) {
436 controlreply ( sender
, "ERROR: large maximum number of clients - %l u" , newvalue
);
439 if ( newvalue
> 10000 ) {
440 controlreply ( sender
, "WARNING: large maximum number of clients - %l u" , newvalue
);
443 tg
-> maxclones
= newvalue
;
444 } else if ( ircd_strcmp ( cargv
[ 1 ], "maxperident" )== 0 ) {
445 oldvalue
= tg
-> maxperident
;
448 newvalue
= oldvalue
+ newvalue
;
451 if ( newvalue
> oldvalue
) {
452 controlreply ( sender
, "ERROR: maxperident cannot be less than 0" );
455 newvalue
= oldvalue
- newvalue
;
457 controlreply ( sender
, "ERROR: maxperident limit would be 0 - unlimited maxclones can only be set with '='" );
464 controlreply ( sender
, "ERROR: MaxPerIdent value should be less then 50 (if set)" );
467 tg
-> maxperident
= newvalue
;
468 } else if ( ircd_strcmp ( cargv
[ 1 ], "maxperip" )== 0 ) {
469 oldvalue
= tg
-> maxperip
;
472 newvalue
= oldvalue
+ newvalue
;
475 if ( newvalue
> oldvalue
) {
476 controlreply ( sender
, "ERROR: maxperip cannot be less than 0" );
479 newvalue
= oldvalue
- newvalue
;
481 controlreply ( sender
, "ERROR: maxperip limit would be 0 - unlimited maxclones can only be set with '='" );
487 if ( newvalue
> 500 ) {
488 controlreply ( sender
, "ERROR: MaxPerIP value should be less then 500 (if set)" );
491 tg
-> maxperip
= newvalue
;
492 } else if ( ircd_strcmp ( cargv
[ 1 ], "expire" )== 0 ) {
493 oldvalue
= tg
-> expire
;
494 expiry
= durationtolong (& cargv
[ 2 ][ 1 ]);
496 if ( expiry
> ( 365 * 86400 ) ) {
497 controlreply ( sender
, "ERROR: Invalid duration given - temporary trusts can not be longer then 1 year" );
503 newvalue
= oldvalue
+ expiry
;
506 newvalue
= oldvalue
- expiry
;
507 if ( newvalue
< getnettime () ) {
508 controlreply ( sender
, "ERROR: Can't set expiry before current nettime - use trustgroupdel to delete trust groups" );
514 newvalue
= getnettime () + expiry
;
518 tg
-> expire
= newvalue
;
519 } else if ( ircd_strcmp ( cargv
[ 1 ], "enforceident" )== 0 ) {
520 oldvalue
= tg
-> enforceident
;
521 if ( ( newvalue
!= 0 && newvalue
!= 1 ) || * mod
!= '=' ) {
522 controlreply ( sender
, "ERROR: enforceident is a boolean setting, that means it can only be 0 or 1, and can only be set by '='" );
525 tg
-> enforceident
= newvalue
;
526 } else if ( ircd_strcmp ( cargv
[ 1 ], "ownerid" )== 0 ) {
527 oldvalue
= tg
-> ownerid
;
529 controlreply ( sender
, "ERROR: Q user ID can only be set by '='" );
532 if ( findtrustgroupbyownerid ( newvalue
) ) {
533 controlreply ( sender
, "ERROR: Q User ID %d already has a trustgroup" , newvalue
);
537 if ( newvalue
> 2147483646 ) {
538 controlreply ( sender
, "ERROR: Invalid Q User ID: %d " , newvalue
);
542 tg
-> ownerid
= newvalue
;
544 controlreply ( sender
, "Modification: %s changed to %l u from %l u for trustgroup %l u" , cargv
[ 1 ], newvalue
, oldvalue
, tg
-> id
);
545 controlwall ( NO_OPER
, NL_TRUSTS
, "Modification: %s changed to %l u from %l u for trustgroup %l u" , cargv
[ 1 ], newvalue
, oldvalue
, tg
-> id
);
547 trustsdb_updatetrustgroup ( tg
);
551 int trust_groupdel ( void * source
, int cargc
, char ** cargv
) {
552 nick
* sender
=( nick
*) source
;
553 trusthost_t
* thptr
, * nthptr
;
555 patricia_node_t
* node
;
558 controlreply ( sender
, "Syntax: trustgroupdel <#id|id>" );
562 if ( cargv
[ 0 ][ 0 ]== '#' ){
563 /* find group by id */
564 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
566 /* find group by id */
567 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
571 controlreply ( sender
, "ERROR: A trustgroup with that ID does not exist." );
576 controlreply ( sender
, "INTERNAL ERROR: Trustgroup has ID 0" );
580 /* we have a trustgroup to remove */
581 int hash
= trusts_gettrusthostgroupidhash ( tg
-> id
);
582 for ( thptr
= trusthostgroupidtable
[ hash
]; thptr
; thptr
= nthptr
) {
583 nthptr
= thptr
-> nextbygroupid
;
584 if ( thptr
-> trustgroup
== tg
) {
586 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
);
587 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
);
588 trustsdb_deletetrusthost ( thptr
);
589 trusthost_free ( thptr
);
590 node
-> exts
[ tgh_ext
] = NULL
;
593 controlwall ( NO_OPER
, NL_TRUSTS
, "removed trustgroup # %l u" , tg
-> id
);
594 controlreply ( sender
, "removed trustgroup # %l u" , tg
-> id
);
595 trustsdb_deletetrustgroup ( tg
);
601 int trust_stats ( void * source
, int cargc
, char ** cargv
) {
602 nick
* sender
=( nick
*) source
;
603 trustgroup_t
* tg
; trusthost_t
* thptr
; int i
;
604 unsigned long thcount
= 0 , ucount
= 0 , mcount
= 0 , tgcount
= 0 ;
605 unsigned long hentries
= 0 ;
606 unsigned long netcount4
[ 33 ];
607 unsigned long netucount4
[ 33 ];
608 unsigned long netmcount4
[ 33 ];
609 unsigned long netcount6
[ 129 ];
610 unsigned long netucount6
[ 129 ];
611 unsigned long netmcount6
[ 129 ];
614 int maxthmask6
= 128 ;
616 for ( i
= 0 ; i
< 33 ; i
++) {
622 for ( i
= 0 ; i
< 129 ; i
++) {
628 for ( i
= 0 ; i
< TRUSTS_HASH_GROUPSIZE
; i
++ ) {
629 for ( tg
= trustgroupidtable
[ i
]; tg
; tg
= tg
-> nextbyid
) {
635 for ( i
= 0 ; i
< TRUSTS_HASH_HOSTSIZE
; i
++ ) {
636 for ( thptr
= trusthostidtable
[ i
]; thptr
; thptr
= thptr
-> nextbyid
) {
640 ucount
+= thptr
-> node
-> usercount
;
641 mcount
+= thptr
-> maxused
;
642 if ( irc_in_addr_is_ipv4 (&(( patricia_node_t
*) thptr
-> node
)-> prefix
-> sin
)) {
643 netcount4
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ]++;
644 netucount4
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ]+= thptr
-> node
-> usercount
;
645 netmcount4
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ]+= thptr
-> maxused
;
646 if ( ((( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 ) < maxthmask4
) {
647 maxthmask4
= ((( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
- 96 );
650 netcount6
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
]++;
651 netucount6
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
]+= thptr
-> node
-> usercount
;
652 netmcount6
[(( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
]+= thptr
-> maxused
;
653 if ( (( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
< maxthmask6
) {
654 maxthmask6
= (( patricia_node_t
*) thptr
-> node
)-> prefix
-> bitlen
;
659 controlreply ( sender
, "Online trust users: %l u" , ucount
);
660 controlreply ( sender
, "Maximum online users: %l u" , mcount
);
661 controlreply ( sender
, "Trust groups: %l u" , tgcount
);
662 controlreply ( sender
, "Maximum group ID: # %l u" , trusts_lasttrustgroupid
);
663 controlreply ( sender
, "Trusted hosts/nets: %l u" , thcount
);
664 controlreply ( sender
, "Largest subnet (v4): / %d " , maxthmask4
);
665 controlreply ( sender
, "Largest subnet (v6): / %d " , maxthmask6
);
666 controlreply ( sender
, "IPv4 Subnets:" );
667 for ( i
= 0 ; i
< 32 ; i
++) {
668 if ( netcount4
[ i
]== 0 ) continue ;
669 controlreply ( sender
, "|-*/ %d (Netcount: %l u Cur: %l u Max: %l u)" , i
, netcount4
[ i
], netucount4
[ i
], netmcount4
[ i
]);
671 controlreply ( sender
, "`-*/32 (Netcount: %l u Cur: %l u Max: %l u)" , netcount4
[ 32 ], netucount4
[ 32 ], netmcount4
[ 32 ]);
672 controlreply ( sender
, "IPv6 Subnets:" );
673 for ( i
= 0 ; i
< 128 ; i
++) {
674 if ( netcount6
[ i
]== 0 ) continue ;
675 controlreply ( sender
, "|-*/ %d (Netcount: %l u Cur: %l u Max: %l u)" , i
, netcount6
[ i
], netucount6
[ i
], netmcount6
[ i
]);
677 controlreply ( sender
, "`-*/128 (Netcount: %l u Cur: %l u Max: %l u)" , netcount6
[ 128 ], netucount6
[ 128 ], netmcount6
[ 128 ]);
683 int trust_comment ( void * source
, int cargc
, char ** cargv
) {
684 nick
* sender
=( nick
*) source
;
688 controlreply ( sender
, "Syntax: trustcomment <#groupid> <comment>" );
692 if ( cargv
[ 0 ][ 0 ]== '#' ){
693 /* find group by id */
694 tg
= findtrustgroupbyid ( strtol (& cargv
[ 0 ][ 1 ], NULL
, 10 ));
696 /* find group by id */
697 tg
= findtrustgroupbyid ( strtol ( cargv
[ 0 ], NULL
, 10 ));
701 controlreply ( sender
, "A trustgroup with that ID does not exist." );
706 controlreply ( sender
, "Internal error: Trustgroup has ID 0" );
710 trustsdb_logmessage ( tg
, 0 , 1 , cargv
[ 1 ]);
712 controlreply ( sender
, "Comment: %s for trustgroup %l u" , cargv
[ 1 ], tg
-> id
);
713 controlwall ( NO_OPER
, NL_TRUSTS
, "Comment: %s for trustgroup %l u" , cargv
[ 1 ], tg
-> id
);