]>
jfr.im git - irc/quakenet/newserv.git/blob - glines/glines_commands.c
4 #include "../lib/version.h"
5 #include "../control/control.h"
6 #include "../lib/irc_string.h"
7 #include "../lib/splitline.h"
8 #include "../lib/strlfunc.h"
9 #include "../core/nsmalloc.h"
10 #include "../irc/irc.h"
11 #include "../localuser/localuser.h"
12 #include "../localuser/localuserchannel.h"
14 #include "../trusts/trusts.h"
18 static void registercommands ( int , void *);
19 static void deregistercommands ( int , void *);
21 static int glines_cmdblock ( void * source
, int cargc
, char ** cargv
) {
22 nick
* sender
= source
;
32 target
= getnickbynick ( cargv
[ 0 ]);
35 controlreply ( sender
, "Sorry, couldn't find that user." );
39 duration
= durationtolong ( cargv
[ 1 ]);
42 controlreply ( sender
, "Invalid duration specified." );
46 if ( duration
> MAXUSERGLINEDURATION
) {
47 controlreply ( sender
, "Sorry, glines may not last longer than %s ." , longtoduration ( MAXUSERGLINEDURATION
, 0 ));
53 if ( strlen ( reason
) < MINUSERGLINEREASON
) {
54 controlreply ( sender
, "Please specify a proper gline reason." );
58 snprintf ( creator
, sizeof ( creator
), "# %s " , sender
-> authname
);
60 glinebufinit (& gbuf
, 1 );
61 glinebufaddbynick (& gbuf
, target
, 0 , creator
, reason
, getnettime () + duration
, getnettime (), getnettime () + duration
);
62 glinebufcounthits (& gbuf
, & hits
, NULL
);
63 glinebufflush (& gbuf
, 1 );
65 controlwall ( NO_OPER
, NL_GLINES
, " %s BLOCK'ed user ' %s ! %s @ %s ' for %s with reason ' %s ' ( %d hits)" , controlid ( sender
), target
-> nick
, target
-> ident
, target
-> host
-> name
-> content
, longtoduration ( duration
, 0 ), reason
, hits
);
67 controlreply ( sender
, "Done." );
72 static int glines_cmdgline ( void * source
, int cargc
, char ** cargv
) {
73 nick
* sender
= source
;
74 int duration
, users
, channels
;
75 char * mask
, * reason
, * pos
;
77 int coff
, sanitychecks
, operlimit
;
79 #if SNIRCD_VERSION < 140
90 if ( cargv
[ 0 ][ 0 ] == '-' ) {
93 for ( pos
= &( cargv
[ 0 ][ 1 ]); * pos
; pos
++) {
102 controlreply ( sender
, "Invalid flag specified: %c " , * pos
);
108 if ( cargc
< 3 + coff
)
113 duration
= durationtolong ( cargv
[ coff
+ 1 ]);
116 controlreply ( sender
, "Invalid duration specified." );
120 if ( duration
> MAXUSERGLINEDURATION
) {
121 controlreply ( sender
, "Sorry, glines may not last longer than %s ." , longtoduration ( MAXUSERGLINEDURATION
, 0 ));
125 rejoinline ( cargv
[ coff
+ 2 ], cargc
- coff
- 2 );
126 reason
= cargv
[ coff
+ 2 ];
128 if ( strlen ( reason
) < MINUSERGLINEREASON
) {
129 controlreply ( sender
, "Please specify a proper gline reason." );
133 #if SNIRCD_VERSION < 140
134 gl
= findgline ( mask
);
137 /* warn opers that they can't modify this gline */
138 if ( gl
-> flags
& GLINE_ACTIVE
) {
139 controlreply ( sender
, "Active G-Line already exists on %s - unable to modify" , mask
);
143 controlreply ( sender
, "Reactivating existing gline on %s " , mask
);
147 snprintf ( creator
, sizeof ( creator
), "# %s " , sender
-> authname
);
149 glinebufinit (& gbuf
, 1 );
151 if (! glinebufadd (& gbuf
, mask
, creator
, reason
, getnettime () + duration
, getnettime (), getnettime () + duration
)) {
152 controlreply ( sender
, "Invalid G-Line mask." );
156 glinebufcounthits (& gbuf
, & users
, & channels
);
159 if ( channels
> MAXUSERGLINECHANNELHITS
) {
160 glinebufabandon (& gbuf
);
161 controlreply ( sender
, "G-Line on ' %s ' would hit %d channels. Limit is %d . Not setting G-Line." , mask
, channels
, MAXUSERGLINECHANNELHITS
);
163 } else if ( users
> MAXUSERGLINEUSERHITS
) {
164 glinebufabandon (& gbuf
);
165 controlreply ( sender
, "G-Line on ' %s ' would hit %d users. Limit is %d . Not setting G-Line." , mask
, users
, MAXUSERGLINEUSERHITS
);
170 if ( sanitychecks
&& glinebufsanitize (& gbuf
) > 0 ) {
171 glinebufabandon (& gbuf
);
172 controlreply ( sender
, "G-Line failed sanity checks. Not setting G-Line." );
176 glinebufflush (& gbuf
, 1 );
178 controlwall ( NO_OPER
, NL_GLINES
, " %s GLINE'd mask ' %s ' for %s with reason ' %s ' (hits %d users/ %d channels)" ,
179 controlid ( sender
), mask
, longtoduration ( duration
, 0 ), reason
, users
, channels
);
181 controlreply ( sender
, "Done." );
186 static int glines_cmdglinesimulate ( void * source
, int cargc
, char ** cargv
) {
187 nick
* sender
= source
;
198 snprintf ( creator
, sizeof ( creator
), "# %s " , sender
-> authname
);
200 glinebufinit (& gbuf
, 0 );
202 if (! glinebufadd (& gbuf
, mask
, creator
, "Simulate" , getnettime (), getnettime (), getnettime ())) {
203 glinebufabandon (& gbuf
);
204 controlreply ( sender
, "Invalid G-Line mask." );
208 glinebufcounthits (& gbuf
, & users
, & channels
);
209 glinebufabandon (& gbuf
);
211 controlreply ( sender
, "G-Line on ' %s ' would hit %d users/ %d channels." , mask
, users
, channels
);
216 static int glines_cmdsmartgline ( void * source
, int cargc
, char ** cargv
) {
217 nick
* sender
= source
;
220 char * p
, * user
, * host
;
221 struct irc_in_addr ip
;
233 if ( origmask
[ 0 ] == '#' || origmask
[ 0 ] == '&' ) {
234 controlreply ( sender
, "Please use \" gline \" for badchans and regex glines." );
238 duration
= durationtolong ( cargv
[ 1 ]);
241 controlreply ( sender
, "Invalid duration specified." );
245 if ( duration
> MAXUSERGLINEDURATION
) {
246 controlreply ( sender
, "Sorry, glines may not last longer than %s ." , longtoduration ( MAXUSERGLINEDURATION
, 0 ));
252 if ( strlen ( reason
) < MINUSERGLINEREASON
) {
253 controlreply ( sender
, "Please specify a proper gline reason." );
257 strncpy ( mask
, origmask
, sizeof ( mask
));
259 if ( strchr ( mask
, '!' )) {
260 controlreply ( sender
, "Use \" gline \" to place nick glines." );
264 p
= strchr ( mask
, '@' );
267 controlreply ( sender
, "Mask must contain a username (e.g. user@ip)." );
275 if ( strchr ( user
, '*' ) || strchr ( user
, '?' )) {
276 controlreply ( sender
, "Usernames may not contain wildcards." );
280 if (! ipmask_parse ( host
, & ip
, & bits
)) {
281 controlreply ( sender
, "Invalid CIDR mask." );
285 snprintf ( creator
, sizeof ( creator
), "# %s " , sender
-> authname
);
287 glinebufinit (& gbuf
, 1 );
288 glinebufaddbyip (& gbuf
, user
, & ip
, 128 , 0 , creator
, reason
, getnettime () + duration
, getnettime (), getnettime () + duration
);
289 glinebufcounthits (& gbuf
, & hits
, NULL
);
290 glinebufflush (& gbuf
, 1 );
292 controlwall ( NO_OPER
, NL_GLINES
, " %s GLINE'd mask ' %s ' for %s with reason ' %s ' ( %d hits)" ,
293 controlid ( sender
), cargv
[ 0 ], longtoduration ( duration
, 0 ), reason
, hits
);
295 controlreply ( sender
, "Done." );
300 static int glines_cmdungline ( void * source
, int cargc
, char ** cargv
) {
301 nick
* sender
= source
;
307 gl
= findgline ( cargv
[ 0 ]);
310 controlreply ( sender
, "No such G-Line." );
314 if (!( gl
-> flags
& GLINE_ACTIVE
)) {
315 controlreply ( sender
, "G-Line was already deactivated." );
319 gline_deactivate ( gl
, 0 , 1 );
321 controlwall ( NO_OPER
, NL_GLINES
, " %s UNGLINE'd mask ' %s '" , controlid ( sender
), cargv
[ 0 ]);
323 controlreply ( sender
, "G-Line deactivated." );
328 static int glines_cmdclearchan ( void * source
, int cargc
, char ** cargv
) {
329 nick
* sender
= source
;
332 char * reason
= "Clearing channel." ;
333 int mode
, duration
, i
, slot
, hits
;
341 cp
= findchannel ( cargv
[ 0 ]);
344 controlreply ( sender
, "Couldn't find that channel." );
348 if ( strcmp ( cargv
[ 1 ], "kick" ) == 0 )
350 else if ( strcmp ( cargv
[ 1 ], "kill" ) == 0 )
352 else if ( strcmp ( cargv
[ 1 ], "gline" ) == 0 )
354 else if ( strcmp ( cargv
[ 1 ], "glineall" ) == 0 )
359 if ( mode
== 0 || mode
== 1 ) {
361 rejoinline ( cargv
[ 2 ], cargc
- 2 );
368 duration
= durationtolong ( cargv
[ 2 ]);
371 controlreply ( sender
, "Invalid duration specified." );
375 if ( duration
> MAXUSERGLINEDURATION
) {
376 controlreply ( sender
, "Sorry, glines may not last longer than %s ." , longtoduration ( MAXUSERGLINEDURATION
, 0 ));
384 array_init (& victims
, sizeof ( nick
*));
386 /* we need to make a list of the channel users here because
387 * kicking/killing them will affect their position in the channel's
389 for ( i
= 0 ; i
< cp
-> users
-> hashsize
; i
++) {
390 if ( cp
-> users
-> content
[ i
] == nouser
)
393 np
= getnickbynumeric ( cp
-> users
-> content
[ i
]);
398 if ( IsService ( np
) || IsOper ( np
) || NickOnServiceServer ( np
))
401 slot
= array_getfreeslot (& victims
);
402 ((( nick
**) victims
. content
)[ slot
]) = np
;
405 snprintf ( creator
, sizeof ( creator
), "# %s " , sender
-> authname
);
407 glinebufinit (& gbuf
, 1 );
409 for ( i
= 0 ; i
< victims
. cursi
; i
++) {
410 np
= (( nick
**) victims
. content
)[ i
];
414 localkickuser ( NULL
, cp
, np
, reason
);
417 killuser ( NULL
, np
, " %s " , reason
);
424 glinebufaddbynick (& gbuf
, np
, 0 , creator
, reason
, getnettime () + duration
, getnettime (), getnettime () + duration
);
431 glinebufcounthits (& gbuf
, & hits
, NULL
);
432 glinebufflush (& gbuf
, 1 );
434 array_free (& victims
);
436 if ( mode
== 0 || mode
== 1 )
437 controlwall ( NO_OPER
, NL_GLINES
, " %s CLEARCHAN'd channel ' %s ' with mode ' %s ' and reason ' %s '" ,
438 controlid ( sender
), cp
-> index
-> name
-> content
, cargv
[ 1 ], reason
);
440 controlwall ( NO_OPER
, NL_GLINES
, " %s CLEARCHAN'd channel ' %s ' with mode ' %s ', duration %s and reason ' %s ' ( %d hits)" ,
441 controlid ( sender
), cp
-> index
-> name
-> content
, cargv
[ 1 ], longtoduration ( duration
, 0 ), reason
, hits
);
443 controlreply ( sender
, "Done." );
448 static int glines_cmdtrustgline ( void * source
, int cargc
, char ** cargv
) {
449 nick
* sender
= source
;
461 tg
= tg_strtotg ( cargv
[ 0 ]);
463 if (!( tg
-> flags
& TRUST_RELIABLE_USERNAME
)) {
464 controlreply ( sender
, "Sorry, that trust group does not have the \" reliable username \" flag." );
468 duration
= durationtolong ( cargv
[ 2 ]);
470 if ( duration
<= 0 || duration
> MAXUSERGLINEDURATION
) {
471 controlreply ( sender
, "Sorry, glines may not last longer than %s ." , longtoduration ( MAXUSERGLINEDURATION
, 0 ));
477 if ( strlen ( reason
) < MINUSERGLINEREASON
) {
478 controlreply ( sender
, "Please specify a proper gline reason." );
482 snprintf ( creator
, sizeof ( creator
), "# %s " , sender
-> authname
);
484 glinebufinit (& gbuf
, 0 );
486 for ( th
= tg
-> hosts
; th
; th
= th
-> next
) {
487 snprintf ( mask
, sizeof ( mask
), "*! %s @ %s " , cargv
[ 1 ], trusts_cidr2str (& th
-> ip
, th
-> bits
));
488 glinebufadd (& gbuf
, mask
, creator
, reason
, getnettime () + duration
, getnettime (), getnettime () + duration
);
491 glinebufcounthits (& gbuf
, & hits
, NULL
);
492 glinebufflush (& gbuf
, 1 );
494 controlwall ( NO_OPER
, NL_GLINES
, " %s TRUSTGLINE'd user ' %s ' on trust group ' %s ' for %s with reason ' %s ' ( %d hits)" ,
495 controlid ( sender
), cargv
[ 1 ], tg
-> name
-> content
, longtoduration ( duration
, 0 ), reason
, hits
);
497 controlreply ( sender
, "Done." );
502 static int glines_cmdtrustungline ( void * source
, int cargc
, char ** cargv
) {
503 nick
* sender
= source
;
513 tg
= tg_strtotg ( cargv
[ 0 ]);
515 if (!( tg
-> flags
& TRUST_RELIABLE_USERNAME
)) {
516 controlreply ( sender
, "Sorry, that trust group does not have the \" reliable username \" flag." );
522 for ( th
= tg
-> hosts
; th
; th
= th
-> next
) {
523 snprintf ( mask
, sizeof ( mask
), "*! %s @ %s " , cargv
[ 1 ], trusts_cidr2str (& th
-> ip
, th
-> bits
));
525 gl
= findgline ( mask
);
527 if ( gl
&& ( gl
-> flags
& GLINE_ACTIVE
)) {
528 gline_deactivate ( gl
, 0 , 1 );
533 controlwall ( NO_OPER
, NL_GLINES
, " %s TRUSTUNGLINE'd user ' %s ' on trust group ' %s ' ( %d G-Lines deactivated)" ,
534 controlid ( sender
), cargv
[ 1 ], tg
-> name
-> content
, count
);
536 controlreply ( sender
, "Done." );
541 static int glines_cmdglstats ( void * source
, int cargc
, char ** cargv
) {
542 nick
* sender
= ( nick
*) source
;
544 time_t curtime
= getnettime ();
545 int glinecount
= 0 , hostglinecount
= 0 , ipglinecount
= 0 , badchancount
= 0 , rnglinecount
= 0 ;
546 int deactivecount
= 0 , activecount
= 0 ;
548 for ( gl
= glinelist
; gl
; gl
= next
) {
551 if ( gl
-> lifetime
<= curtime
) {
554 } else if ( gl
-> expire
<= curtime
) {
555 gl
-> flags
&= ~ GLINE_ACTIVE
;
558 if ( gl
-> flags
& GLINE_ACTIVE
) {
564 if ( gl
-> flags
& GLINE_IPMASK
)
566 else if ( gl
-> flags
& GLINE_HOSTMASK
)
568 else if ( gl
-> flags
& GLINE_REALNAME
)
570 else if ( gl
-> flags
& GLINE_BADCHAN
)
575 controlreply ( sender
, "Total G-Lines set: %d " , glinecount
);
576 controlreply ( sender
, "Hostmask G-Lines: %d " , hostglinecount
);
577 controlreply ( sender
, "IPMask G-Lines: %d " , ipglinecount
);
578 controlreply ( sender
, "Channel G-Lines: %d " , badchancount
);
579 controlreply ( sender
, "Realname G-Lines: %d " , rnglinecount
);
581 controlreply ( sender
, "Active G-Lines: %d " , activecount
);
582 controlreply ( sender
, "Inactive G-Lines: %d " , deactivecount
);
584 /* TODO show top 10 creators here */
585 /* TODO show unique creators count */
586 /* TODO show glines per create %8.1f", ccount?((float)gcount/(float)ccount):0 */
590 static int glines_cmdglist ( void * source
, int cargc
, char ** cargv
) {
591 nick
* sender
= ( nick
*) source
;
593 time_t curtime
= time ( NULL
);
600 if ( cargc
< 1 || ( cargc
== 1 && cargv
[ 0 ][ 0 ] == '-' )) {
601 controlreply ( sender
, "Syntax: glist [-flags] <mask>" );
602 controlreply ( sender
, "Valid flags are:" );
603 controlreply ( sender
, "-c: Count G-Lines." );
604 controlreply ( sender
, "-f: Find G-Lines active on <mask>." );
605 controlreply ( sender
, "-x: Find G-Lines matching <mask> exactly." );
606 controlreply ( sender
, "-R: Find G-lines on realnames." );
607 controlreply ( sender
, "-o: Search for glines by owner." );
608 controlreply ( sender
, "-r: Search for glines by reason." );
609 controlreply ( sender
, "-i: Include inactive glines." );
624 flags
|= GLIST_COUNT
;
632 flags
|= GLIST_EXACT
;
636 flags
|= GLIST_REASON
;
639 flags
|= GLIST_OWNER
;
643 flags
|= GLIST_REALNAME
;
647 flags
|= GLIST_INACTIVE
;
651 controlreply ( sender
, "Invalid flag ' %c '." , * ch
);
660 if (( flags
& ( GLIST_EXACT
| GLIST_FIND
)) == ( GLIST_EXACT
| GLIST_FIND
)) {
661 controlreply ( sender
, "You cannot use -x and -f flags together." );
665 if (!( flags
& GLIST_COUNT
))
666 controlreply ( sender
, "%-50s %-19s %-25s %s " , "Mask:" , "Expires in:" , "Creator:" , "Reason:" );
668 gline
* searchgl
= makegline ( mask
);
670 for ( gl
= glinelist
; gl
; gl
= next
) {
673 if ( gl
-> lifetime
<= curtime
) {
676 } else if ( gl
-> expire
<= curtime
) {
677 gl
-> flags
&= ~ GLINE_ACTIVE
;
680 if (!( gl
-> flags
& GLINE_ACTIVE
)) {
681 if (!( flags
& GLIST_INACTIVE
)) {
686 if ( flags
& GLIST_REALNAME
) {
687 if (!( gl
-> flags
& GLINE_REALNAME
))
689 if ( flags
& GLIST_EXACT
) {
690 if (! glineequal ( searchgl
, gl
)) {
693 } else if ( flags
& GLIST_FIND
) {
694 if (! gline_match_mask ( searchgl
, gl
)) {
699 if ( gl
-> flags
& GLINE_REALNAME
)
702 if ( flags
& GLIST_REASON
) {
703 if ( flags
& GLIST_EXACT
) {
704 if (! gl
-> reason
|| ircd_strcmp ( mask
, gl
-> reason
-> content
) != 0 )
706 } else if ( flags
& GLIST_FIND
) {
707 if (! gl
-> reason
|| match ( gl
-> reason
-> content
, mask
))
709 } else if (! gl
-> reason
|| match ( mask
, gl
-> reason
-> content
))
711 } else if ( flags
& GLIST_OWNER
) {
712 if ( flags
& GLIST_EXACT
) {
713 if (! gl
-> creator
|| ircd_strcmp ( mask
, gl
-> creator
-> content
) != 0 )
715 } else if ( flags
& GLIST_FIND
) {
716 if (! gl
-> creator
|| match ( gl
-> creator
-> content
, mask
))
718 } else if (! gl
-> creator
|| match ( mask
, gl
-> creator
-> content
))
721 if ( flags
& GLIST_EXACT
) {
722 if (! glineequal ( searchgl
, gl
)) {
725 } else if ( flags
& GLIST_FIND
) {
726 if (! gline_match_mask ( searchgl
, gl
)) {
733 if ( count
== limit
&& !( flags
& GLIST_COUNT
))
734 controlreply ( sender
, "More than %d matches, list truncated." , limit
);
738 if (!( flags
& GLIST_COUNT
) && count
< limit
) {
739 snprintf ( tmp
, 249 , " %s " , glinetostring ( gl
));
740 controlreply ( sender
, " %s %-49s %-19s %-25s %s " ,
741 ( gl
-> flags
& GLINE_ACTIVE
) ? "+" : "-" ,
743 ( gl
-> flags
& GLINE_ACTIVE
) ? ( char *) longtoduration ( gl
-> expire
- curtime
, 0 ) : "<inactive>" ,
744 gl
-> creator
? gl
-> creator
-> content
: "" ,
745 gl
-> reason
? gl
-> reason
-> content
: "" );
749 controlreply ( sender
, " %s%d G-Line %s found." , ( flags
& GLIST_COUNT
) ? "" : "End of list - " , count
, count
== 1 ? "" : "s" );
754 static int glines_cmdcleanupglines ( void * source
, int cargc
, char ** cargv
) {
755 nick
* sender
= source
;
763 for ( pnext
= & glinelist
; * pnext
; pnext
= &((* pnext
)-> next
)) {
766 /* Remove inactivate glines that have been last changed more than a week ago */
767 if (!( gl
-> flags
& GLINE_ACTIVE
) && gl
-> lastmod
< now
- 7 * 24 * 60 * 60 ) {
768 gline_destroy ( gl
, 0 , 1 );
776 controlwall ( NO_OPER
, NL_GLINES
, " %s CLEANUPGLINES'd %d G-Lines." ,
777 controlid ( sender
), count
);
779 controlreply ( sender
, "Done." );
784 static int glines_cmdsyncglines ( void * source
, int cargc
, char ** cargv
) {
785 nick
* sender
= source
;
791 for ( gl
= glinelist
; gl
; gl
= gl
-> next
) {
796 controlwall ( NO_OPER
, NL_GLINES
, " %s SYNCGLINE'd %d G-Lines." ,
797 controlid ( sender
), count
);
799 controlreply ( sender
, "Done." );
804 static int glines_cmdsaveglines ( void * source
, int cargc
, char ** cargv
) {
805 nick
* sender
= source
;
808 count
= glstore_save ();
811 controlreply ( sender
, "An error occured while saving G-Lines." );
813 controlreply ( sender
, "Saved %d G-Line %s ." , count
, ( count
== 1 ) ? "" : "s" );
818 static int glines_cmdloadglines ( void * source
, int cargc
, char ** cargv
) {
819 nick
* sender
= source
;
822 count
= glstore_load ();
825 controlreply ( sender
, "An error occured while loading the G-Lines file." );
827 controlreply ( sender
, "Loaded %d G-Line %s ." , count
, ( count
== 1 ) ? "" : "s" );
832 static int commandsregistered
;
834 static void registercommands ( int hooknum
, void * arg
) {
835 if ( commandsregistered
)
837 commandsregistered
= 1 ;
839 registercontrolhelpcmd ( "block" , NO_OPER
, 3 , glines_cmdblock
, "Usage: block <nick> <duration> <reason> \n Sets a gline using an appropriate mask given the user's nickname." );
840 registercontrolhelpcmd ( "gline" , NO_OPER
, 4 , glines_cmdgline
, "Usage: gline ?flags? <mask> <duration> <reason> \n Sets a gline. Flags can be one or more of: \n -S - bypass sanity checks \n -l - bypass hit limits" );
841 registercontrolhelpcmd ( "glinesimulate" , NO_OPER
, 1 , glines_cmdglinesimulate
, "Usage: glinesimulate <mask> \n Simulates what happens when a gline is set." );
842 registercontrolhelpcmd ( "smartgline" , NO_OPER
, 3 , glines_cmdsmartgline
, "Usage: smartgline <user@host> <duration> <reason> \n Sets a gline. Automatically adjusts the mask depending on whether the specified mask is trusted." );
843 registercontrolhelpcmd ( "ungline" , NO_OPER
, 1 , glines_cmdungline
, "Usage: ungline <mask> \n Deactivates a gline." );
844 registercontrolhelpcmd ( "clearchan" , NO_OPER
, 4 , glines_cmdclearchan
, "Usage: clearchan <#channel> <how> <duration> ?reason? \n Clears a channel. \n how can be one of: \n kick - Kicks users. \n kill - Kills users. \n gline - Glines non-authed users (using an appropriate mask). \n glineall - Glines users. \n Duration is only valid when glining users. Reason defaults to \" Clearing channel. \" ." );
845 registercontrolhelpcmd ( "trustgline" , NO_OPER
, 4 , glines_cmdtrustgline
, "Usage: trustgline <#id|name> <user> <duration> <reason> \n Sets a gline on the specified username for each host in the specified trust group. The username may contain wildcards." );
846 registercontrolhelpcmd ( "trustungline" , NO_OPER
, 2 , glines_cmdtrustungline
, "Usage: trustungline <#id|name> <user> \n Removes a gline that was previously set with trustgline." );
847 registercontrolhelpcmd ( "glstats" , NO_OPER
, 0 , glines_cmdglstats
, "Usage: glstat \n Shows statistics about G-Lines." );
848 registercontrolhelpcmd ( "glist" , NO_OPER
, 2 , glines_cmdglist
, "Usage: glist [-flags] <mask> \n Lists matching G-Lines. \n Valid flags are: \n -c: Count G-Lines. \n -f: Find G-Lines active on <mask>. \n -x: Find G-Lines matching <mask> exactly. \n -R: Find G-lines on realnames. \n -o: Search for glines by owner. \n -r: Search for glines by reason. \n -i: Include inactive glines." );
849 registercontrolhelpcmd ( "cleanupglines" , NO_OPER
, 0 , glines_cmdcleanupglines
, "Usage: cleanupglines \n Destroys all deactivated G-Lines." );
850 registercontrolhelpcmd ( "syncglines" , NO_DEVELOPER
, 0 , glines_cmdsyncglines
, "Usage: syncglines \n Sends all G-Lines to all other servers." );
851 registercontrolhelpcmd ( "loadglines" , NO_DEVELOPER
, 0 , glines_cmdloadglines
, "Usage: loadglines \n Force load of glines." );
852 registercontrolhelpcmd ( "saveglines" , NO_DEVELOPER
, 0 , glines_cmdsaveglines
, "Usage: saveglines \n Force save of glines." );
855 static void deregistercommands ( int hooknum
, void * arg
) {
856 if (! commandsregistered
)
858 commandsregistered
= 0 ;
860 deregistercontrolcmd ( "block" , glines_cmdblock
);
861 deregistercontrolcmd ( "gline" , glines_cmdgline
);
862 deregistercontrolcmd ( "glinesimulate" , glines_cmdglinesimulate
);
863 deregistercontrolcmd ( "smartgline" , glines_cmdsmartgline
);
864 deregistercontrolcmd ( "ungline" , glines_cmdungline
);
865 deregistercontrolcmd ( "clearchan" , glines_cmdclearchan
);
866 deregistercontrolcmd ( "trustgline" , glines_cmdtrustgline
);
867 deregistercontrolcmd ( "trustungline" , glines_cmdtrustungline
);
868 deregistercontrolcmd ( "glstats" , glines_cmdglstats
);
869 deregistercontrolcmd ( "glist" , glines_cmdglist
);
870 deregistercontrolcmd ( "cleanupglines" , glines_cmdcleanupglines
);
871 deregistercontrolcmd ( "syncglines" , glines_cmdsyncglines
);
872 deregistercontrolcmd ( "loadglines" , glines_cmdloadglines
);
873 deregistercontrolcmd ( "saveglines" , glines_cmdsaveglines
);
877 registerhook ( HOOK_TRUSTS_DB_LOADED
, registercommands
);
878 registerhook ( HOOK_TRUSTS_DB_CLOSED
, deregistercommands
);
881 registercommands ( 0 , NULL
);
885 deregisterhook ( HOOK_TRUSTS_DB_LOADED
, registercommands
);
886 deregisterhook ( HOOK_TRUSTS_DB_CLOSED
, deregistercommands
);
888 deregistercommands ( 0 , NULL
);