diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 4ab221fa..b09e1824 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -19,6 +19,7 @@ extension_LTLIBRARIES = \ extb_account.la \ extb_canjoin.la \ extb_channel.la \ + extb_guest.la \ extb_hostmask.la \ extb_oper.la \ extb_server.la \ diff --git a/extensions/README b/extensions/README index 358b9dcc..16b107ce 100644 --- a/extensions/README +++ b/extensions/README @@ -79,6 +79,7 @@ extb_account.so - Account bans (+b $a[:mask]) extb_canjoin.so - Banned from another channel (+b $j:mask) extb_channel.so - Other-channel bans (+b $c:mask) extb_extgecos.so - Extended ban (+b $x:mask) +extb_guest.so - Unidentified bans (+b $g:mask) extb_oper.so - Oper bans (+b $o) extb_realname.so - Realname (gecos) bans (+b $r:mask) extb_server.so - Server bans (+b $s:mask) diff --git a/extensions/extb_guest.c b/extensions/extb_guest.c new file mode 100644 index 00000000..22a1e436 --- /dev/null +++ b/extensions/extb_guest.c @@ -0,0 +1,73 @@ +/* + * Guest extban type: bans unidentified users matching nick!user@host. + * -- TheDaemoness + */ + +#include "stdinc.h" +#include "modules.h" +#include "client.h" +#include "ircd.h" + +static const char extb_desc[] = "Guest ($g) extban type - bans unidentified users matching nick!user@host"; + +static int _modinit(void); +static void _moddeinit(void); +static int eb_guest(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); + +DECLARE_MODULE_AV2(extb_guest, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc); + +static int +_modinit(void) +{ + extban_table['g'] = eb_guest; + + return 0; +} + +static void +_moddeinit(void) +{ + extban_table['g'] = NULL; +} + +static int eb_guest(const char *data, struct Client *client_p, + struct Channel *chptr, long mode_type) +{ + (void)chptr; + + if (data == NULL) + return EXTBAN_INVALID; + + const char *idx = strchr(data, '#'); + + if (idx != NULL && idx[1] == '\0') + /* Users cannot have empty realnames, + * so don't let a ban be set matching one + */ + return EXTBAN_INVALID; + + if (!EmptyString(client_p->user->suser)) + return EXTBAN_NOMATCH; + + if (idx != NULL) + { + char buf[BUFSIZE]; + + // Copy the nick!user@host part of the ban + memcpy(buf, data, (idx - data)); + buf[(idx - data)] = '\0'; + + // Advance to the realname part of the ban + idx++; + + if (client_matches_mask(client_p, buf) && match(idx, client_p->info)) + return EXTBAN_MATCH; + + return EXTBAN_NOMATCH; + } + + if (client_matches_mask(client_p, data)) + return EXTBAN_MATCH; + + return EXTBAN_NOMATCH; +} diff --git a/help/opers/extban b/help/opers/extban index 5a0e8e68..73a979dd 100644 --- a/help/opers/extban +++ b/help/opers/extban @@ -19,6 +19,7 @@ Unless noted below, all types can be used with +b, +q, +e and +I. $a: - Matches users logged in with a username matching the mask (* and ? wildcards) $c: - Matches users who are on the given channel + $g: - Matches as a normal ban but excludes logged in users $o - Matches opers (most useful with +I) $r: - Matches users with a realname (gecos) matching the mask (* and ? wildcards); this can only be used with +b and +q