1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-28 00:46:37 +02:00

Move all built-in extended bans to modules/extbans/...

This commit is contained in:
Bram Matthys
2015-06-05 15:38:01 +02:00
parent 0994c9431f
commit de59bf47ef
15 changed files with 767 additions and 289 deletions
Vendored
+2 -1
View File
@@ -7798,7 +7798,7 @@ fi
UNRLINCDIR="`pwd`/include"
ac_config_files="$ac_config_files Makefile src/modules/Makefile src/modules/chanmodes/Makefile src/modules/usermodes/Makefile unreal ircdcron/ircdchk ircdcron/ircd.cron"
ac_config_files="$ac_config_files Makefile src/modules/Makefile src/modules/chanmodes/Makefile src/modules/usermodes/Makefile src/modules/extbans/Makefile unreal ircdcron/ircdchk ircdcron/ircd.cron"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -8495,6 +8495,7 @@ do
"src/modules/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/Makefile" ;;
"src/modules/chanmodes/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/chanmodes/Makefile" ;;
"src/modules/usermodes/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/usermodes/Makefile" ;;
"src/modules/extbans/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/extbans/Makefile" ;;
"unreal") CONFIG_FILES="$CONFIG_FILES unreal" ;;
"ircdcron/ircdchk") CONFIG_FILES="$CONFIG_FILES ircdcron/ircdchk" ;;
"ircdcron/ircd.cron") CONFIG_FILES="$CONFIG_FILES ircdcron/ircd.cron" ;;
+1
View File
@@ -734,6 +734,7 @@ AC_CONFIG_FILES([Makefile
src/modules/Makefile
src/modules/chanmodes/Makefile
src/modules/usermodes/Makefile
src/modules/extbans/Makefile
unreal
ircdcron/ircdchk
ircdcron/ircd.cron])
-2
View File
@@ -180,11 +180,9 @@ extern long get_access(aClient *, aChannel *);
extern int is_chan_op(aClient *, aChannel *);
extern int has_voice(aClient *, aChannel *);
extern int is_chanowner(aClient *, aChannel *);
#ifndef DISABLE_EXTBAN_STACKING
extern int ban_check_mask(aClient *, aChannel *, char *, int, int);
extern int extban_is_ok_nuh_extban(aClient *, aChannel *, char *, int, int, int);
extern char* extban_conv_param_nuh_or_extban(char *);
#endif
extern Ban *is_banned(aClient *, aChannel *, int);
extern Ban *is_banned_with_nick(aClient *, aChannel *, int, char *);
extern int parse_help(aClient *, char *, char *);
+9
View File
@@ -137,3 +137,12 @@ loadmodule "modules/chanmodes/secureonly"; /* +z */
/*** User modes ***/
loadmodule "modules/usermodes/noctcp"; /* +T */
loadmodule "modules/usermodes/censor"; /* +G */
/*** Extended Bans ***/
loadmodule "modules/extbans/join"; /* +b ~j */
loadmodule "modules/extbans/quiet"; /* +b ~q */
loadmodule "modules/extbans/nickchange"; /* +b ~n */
loadmodule "modules/extbans/realname"; /* +b ~r */
loadmodule "modules/extbans/regnick"; /* +b ~R */
loadmodule "modules/extbans/account"; /* +b ~a */
loadmodule "modules/extbans/inchannel"; /* +b ~c */
-285
View File
@@ -150,149 +150,6 @@ char tmpbuf[512];
* least the '~t:' part (t=type). -- Syzop
*/
/* TODO: just get rid of strchr */
char *extban_modec_conv_param(char *para)
{
static char retbuf[CHANNELLEN+6];
char *chan, *p, symbol='\0';
strlcpy(retbuf, para, sizeof(retbuf));
chan = retbuf+3;
if ((*chan == '+') || (*chan == '%') || (*chan == '%') ||
(*chan == '@') || (*chan == '&') || (*chan == '~'))
chan++;
if ((*chan != '#') && (*chan != '*') && (*chan != '?'))
return NULL;
if (strlen(chan) > CHANNELLEN)
chan[CHANNELLEN] = '\0';
clean_channelname(chan);
p = strchr(chan, ':'); /* ~r:#chan:*.blah.net is not allowed (for now) */
if (p)
*p = '\0';
/* on a sidenote '#' is allowed because it's a valid channel (atm) */
return retbuf;
}
/* The only purpose of this function is a temporary workaround to prevent a desynch.. pfff */
int extban_modec_is_ok(aClient *sptr, aChannel *chptr, char *para, int checkt, int what, int what2)
{
char *p;
if ((checkt == EXBCHK_PARAM) && MyClient(sptr) && (what == MODE_ADD) && (strlen(para) > 3))
{
p = para + 3;
if ((*p == '+') || (*p == '%') || (*p == '%') ||
(*p == '@') || (*p == '&') || (*p == '~'))
p++;
if (*p != '#')
{
sendnotice(sptr, "Please use a # in the channelname (eg: ~c:#*blah*)");
return 0;
}
}
return 1;
}
static int extban_modec_compareflags(char symbol, int flags)
{
int require=0;
if (symbol == '+')
require = CHFL_VOICE|CHFL_HALFOP|CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '%')
require = CHFL_HALFOP|CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '@')
require = CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '&')
require = CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '~')
require = CHFL_CHANOWNER;
if (flags & require)
return 1;
return 0;
}
int extban_modec_is_banned(aClient *sptr, aChannel *chptr, char *ban, int type)
{
Membership *lp;
char *p = ban+3, symbol = '\0';
if (*p != '#')
{
symbol = *p;
p++;
}
for (lp = sptr->user->channel; lp; lp = lp->next)
{
if (!match_esc(p, lp->chptr->chname))
{
/* Channel matched, check symbol if needed (+/%/@/etc) */
if (symbol)
{
if (extban_modec_compareflags(symbol, lp->flags))
return 1;
} else
return 1;
}
}
return 0;
}
int extban_modeq_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin + 3;
if (type != BANCHK_MSG)
return 0;
#ifdef DISABLE_STACKED_EXTBANS
return extban_is_banned_helper(ban);
#else
return ban_check_mask(sptr, chptr, ban, type, 0);
#endif
}
int extban_moden_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin + 3;
if (type != BANCHK_NICK)
return 0;
if (has_voice(sptr, chptr))
return 0;
#ifdef DISABLE_STACKED_EXTBANS
return extban_is_banned_helper(ban);
#else
return ban_check_mask(sptr, chptr, ban, type, 0);
#endif
}
/* a ban that affects JOINs only */
int extban_modej_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *sub_ban;
if (type != BANCHK_JOIN)
return 0;
sub_ban = banin + 3;
#ifdef DISABLE_STACKED_EXTBANS
return extban_is_banned_helper(sub_ban);
#else
return ban_check_mask(sptr, chptr, sub_ban, type, 0);
#endif
}
#ifndef DISABLE_STACKED_EXTBANS
/** General is_ok for n!u@h stuff that also deals with recursive extbans.
*/
int extban_is_ok_nuh_extban(aClient* sptr, aChannel* chptr, char* para, int checkt, int what, int what2)
@@ -337,8 +194,6 @@ int extban_is_ok_nuh_extban(aClient* sptr, aChannel* chptr, char* para, int chec
}
return 1; /* Either not an extban, or extban has NULL is_ok. Good to go. */
}
#endif
/** Some kind of general conv_param routine,
* to ensure the parameter is nick!user@host.
@@ -374,7 +229,6 @@ char pfix[8];
return retbuf;
}
#ifndef DISABLE_STACKED_EXTBANS
/** conv_param to deal with stacked extbans.
*/
char* extban_conv_param_nuh_or_extban(char* para)
@@ -466,142 +320,3 @@ char* extban_conv_param_nuh_or_extban(char* para)
return extban_conv_param_nuh(para);
}
}
#endif
/** Realname bans - conv_param */
char *extban_moder_conv_param(char *para)
{
char *mask;
static char retbuf[REALLEN + 8];
strlcpy(retbuf, para, sizeof(retbuf));
mask = retbuf+3;
if (strlen(mask) > REALLEN + 3)
mask[REALLEN + 3] = '\0';
if (*mask == '~')
*mask = '?'; /* Is this good? No ;) */
return retbuf;
}
int extban_moder_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin+3;
if (!match_esc(ban, sptr->info))
return 1;
return 0;
}
/** Registered user ban */
char *extban_modeR_conv_param(char *para)
{
static char retbuf[NICKLEN + 4];
strlcpy(retbuf, para, sizeof(retbuf));
if (do_nick_name(retbuf+3) == 0)
return NULL;
return retbuf;
}
int extban_modeR_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin+3;
if (IsRegNick(sptr) && !strcasecmp(ban, sptr->name))
return 1;
return 0;
}
/** Account bans */
char *extban_modea_conv_param(char *para)
{
char *mask;
static char retbuf[NICKLEN + 4];
strlcpy(retbuf, para, sizeof(retbuf)); /* truncate */
if (!strcmp(retbuf+3, "0"))
return NULL; /* ~a:0 would mean ban all non-regged, but we already have +R for that. */
return retbuf;
}
int extban_modea_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin+3;
if (!stricmp(ban, sptr->user->svid))
return 1;
return 0;
}
void extban_init(void)
{
ExtbanInfo req;
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'q';
#ifdef DISABLE_STACKED_EXTBANS
req.conv_param = extban_conv_param_nuh;
#else
req.conv_param = extban_conv_param_nuh_or_extban;
req.is_ok = extban_is_ok_nuh_extban;
#endif
req.options = EXTBOPT_ACTMODIFIER;
req.is_banned = extban_modeq_is_banned;
ExtbanAdd(NULL, req);
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'j';
#ifdef DISABLE_STACKED_EXTBANS
req.conv_param = extban_conv_param_nuh;
#else
req.conv_param = extban_conv_param_nuh_or_extban;
req.is_ok = extban_is_ok_nuh_extban;
#endif
req.is_banned = extban_modej_is_banned;
req.options = EXTBOPT_ACTMODIFIER;
ExtbanAdd(NULL, req);
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'n';
#ifdef DISABLE_STACKED_EXTBANS
req.conv_param = extban_conv_param_nuh;
#else
req.conv_param = extban_conv_param_nuh_or_extban;
req.is_ok = extban_is_ok_nuh_extban;
#endif
req.is_banned = extban_moden_is_banned;
req.options = EXTBOPT_ACTMODIFIER;
ExtbanAdd(NULL, req);
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'c';
req.conv_param = extban_modec_conv_param;
req.is_banned = extban_modec_is_banned;
req.is_ok = extban_modec_is_ok;
req.options = EXTBOPT_INVEX;
ExtbanAdd(NULL, req);
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'r';
req.conv_param = extban_moder_conv_param;
req.is_banned = extban_moder_is_banned;
req.options = EXTBOPT_CHSVSMODE|EXTBOPT_INVEX;
ExtbanAdd(NULL, req);
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'R';
req.conv_param = extban_modeR_conv_param;
req.is_banned = extban_modeR_is_banned;
req.options = EXTBOPT_INVEX;
ExtbanAdd(NULL, req);
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'a';
req.conv_param = extban_modea_conv_param;
req.is_banned = extban_modea_is_banned;
req.options = EXTBOPT_INVEX;
ExtbanAdd(NULL, req);
/* When adding new extbans, be sure to always add a prior memset like above
* so you don't "inherit" old options (we are 2005 and the 20 nanoseconds
* per-boot/rehash is NOT EXACTLY a problem....) -- Syzop.
*/
}
-1
View File
@@ -1173,7 +1173,6 @@ int InitwIRCD(int argc, char *argv[])
tkl_init();
umode_init();
extcmode_init();
extban_init();
init_random(); /* needs to be done very early!! */
clear_scache_hash_table();
#ifdef FORCE_CORE
+1
View File
@@ -67,6 +67,7 @@ all: build
build: $(MODULES)
cd chanmodes; $(MAKE) all
cd usermodes; $(MAKE) all
cd extbans; $(MAKE) all
custommodule: $(MODULEFILE).c
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
+85
View File
@@ -0,0 +1,85 @@
#************************************************************************
#* IRC - Internet Relay Chat, src/modules/chanmodes/Makefile
#* Copyright (C) Carsten V. Munk 2001 & The UnrealIRCd Team
#*
#* This program is free software; you can redistribute it and/or modify
#* it under the terms of the GNU General Public License as published by
#* the Free Software Foundation; either version 1, or (at your option)
#* any later version.
#*
#* This program is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU General Public License for more details.
#*
#* You should have received a copy of the GNU General Public License
#* along with this program; if not, write to the Free Software
#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#*/
INCLUDES = ../../include/auth.h ../../include/channel.h \
../../include/class.h ../../include/common.h ../../include/config.h ../../include/dbuf.h \
../../include/dynconf.h ../../include/events.h ../../include/fdlist.h ../../include/h.h \
../../include/hash.h ../../include/inet.h ../../include/ircsprintf.h \
../../include/license.h ../../include/macros.h \
../../include/modules.h ../../include/modversion.h ../../include/msg.h \
../../include/numeric.h ../../include/proto.h ../../include/res.h \
../../include/resource.h ../../include/setup.h ../../include/sjoin.h \
../../include/sock.h ../../include/ssl.h ../../include/struct.h ../../include/sys.h \
../../include/threads.h ../../include/types.h ../../include/url.h \
../../include/version.h ../../include/whowas.h
R_MODULES= \
join.so quiet.so nickchange.so inchannel.so realname.so regnick.so account.so
MODULES=$(R_MODULES)
MODULEFLAGS=@MODULEFLAGS@
CC=@CC@
RM=@RM@
all: build
build: $(MODULES)
custommodule: $(MODULEFILE).c
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o $(MODULEFILE).so $(MODULEFILE).c $(EXLIBS)
clean:
$(RM) -f *.o *.so *~ core
#############################################################################
# .so's section
#############################################################################
skel.so: skel.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o skel.so skel.c
join.so: join.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o join.so join.c
quiet.so: quiet.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o quiet.so quiet.c
nickchange.so: nickchange.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o nickchange.so nickchange.c
inchannel.so: inchannel.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o inchannel.so inchannel.c
realname.so: realname.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o realname.so realname.c
regnick.so: regnick.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o regnick.so regnick.c
account.so: account.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o account.so account.c
+89
View File
@@ -0,0 +1,89 @@
/*
* Extended ban to ban/exempt by services account (~b ~a:accountname)
* (C) Copyright 2011-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(account)
= {
"chanmodes/extbans/account",
"$Id$",
"ExtBan ~a - Ban/exempt by services account name",
"3.2-b8-1",
NULL
};
/* Forward declarations */
char *extban_account_conv_param(char *para);
int extban_account_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(account)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'a';
req.is_ok = NULL;
req.conv_param = extban_account_conv_param;
req.is_banned = extban_account_is_banned;
req.options = EXTBOPT_ACTMODIFIER; // or not !
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(account)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(account)(int module_unload)
{
return MOD_SUCCESS;
}
/** Account bans */
char *extban_account_conv_param(char *para)
{
char *mask;
static char retbuf[NICKLEN + 4];
strlcpy(retbuf, para, sizeof(retbuf)); /* truncate */
if (!strcmp(retbuf+3, "0"))
return NULL; /* ~a:0 would mean ban all non-regged, but we already have +R for that. */
return retbuf;
}
int extban_account_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin+3;
if (!stricmp(ban, sptr->user->svid))
return 1;
return 0;
}
+165
View File
@@ -0,0 +1,165 @@
/*
* Extended ban: "in channel?" (+b ~c:#chan)
* (C) Copyright 2003-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(inchannel)
= {
"chanmodes/extbans/inchannel",
"$Id$",
"ExtBan ~c - banned when in specified channel",
"3.2-b8-1",
NULL
};
/* Forward declarations */
int extban_inchannel_is_ok(aClient *sptr, aChannel *chptr, char *para, int checkt, int what, int what2);
char *extban_inchannel_conv_param(char *para);
int extban_inchannel_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(inchannel)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'c';
req.is_ok = extban_inchannel_is_ok;
req.conv_param = extban_inchannel_conv_param;
req.is_banned = extban_inchannel_is_banned;
req.options = EXTBOPT_INVEX; /* for +I too */
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(inchannel)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(inchannel)(int module_unload)
{
return MOD_SUCCESS;
}
char *extban_inchannel_conv_param(char *para)
{
static char retbuf[CHANNELLEN+6];
char *chan, *p, symbol='\0';
strlcpy(retbuf, para, sizeof(retbuf));
chan = retbuf+3;
if ((*chan == '+') || (*chan == '%') || (*chan == '%') ||
(*chan == '@') || (*chan == '&') || (*chan == '~'))
chan++;
if ((*chan != '#') && (*chan != '*') && (*chan != '?'))
return NULL;
if (strlen(chan) > CHANNELLEN)
chan[CHANNELLEN] = '\0';
clean_channelname(chan);
p = strchr(chan, ':'); /* ~r:#chan:*.blah.net is not allowed (for now) */
if (p)
*p = '\0';
/* on a sidenote '#' is allowed because it's a valid channel (atm) */
return retbuf;
}
/* The only purpose of this function is a temporary workaround to prevent a desynch.. pfff */
int extban_inchannel_is_ok(aClient *sptr, aChannel *chptr, char *para, int checkt, int what, int what2)
{
char *p;
if ((checkt == EXBCHK_PARAM) && MyClient(sptr) && (what == MODE_ADD) && (strlen(para) > 3))
{
p = para + 3;
if ((*p == '+') || (*p == '%') || (*p == '%') ||
(*p == '@') || (*p == '&') || (*p == '~'))
p++;
if (*p != '#')
{
sendnotice(sptr, "Please use a # in the channelname (eg: ~c:#*blah*)");
return 0;
}
}
return 1;
}
static int extban_inchannel_compareflags(char symbol, int flags)
{
int require=0;
if (symbol == '+')
require = CHFL_VOICE|CHFL_HALFOP|CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '%')
require = CHFL_HALFOP|CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '@')
require = CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '&')
require = CHFL_CHANPROT|CHFL_CHANOWNER;
else if (symbol == '~')
require = CHFL_CHANOWNER;
if (flags & require)
return 1;
return 0;
}
int extban_inchannel_is_banned(aClient *sptr, aChannel *chptr, char *ban, int type)
{
Membership *lp;
char *p = ban+3, symbol = '\0';
if (*p != '#')
{
symbol = *p;
p++;
}
for (lp = sptr->user->channel; lp; lp = lp->next)
{
if (!match_esc(p, lp->chptr->chname))
{
/* Channel matched, check symbol if needed (+/%/@/etc) */
if (symbol)
{
if (extban_inchannel_compareflags(symbol, lp->flags))
return 1;
} else
return 1;
}
}
return 0;
}
+78
View File
@@ -0,0 +1,78 @@
/*
* Extended ban that affects JOIN only (+b ~j)
* (C) Copyright 2003-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(join)
= {
"chanmodes/extbans/join",
"$Id$",
"Extban ~j - prevent join only",
"3.2-b8-1",
NULL
};
/* Forward declarations */
int extban_modej_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(join)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'j';
req.is_ok = extban_is_ok_nuh_extban;
req.conv_param = extban_conv_param_nuh_or_extban;
req.is_banned = extban_modej_is_banned;
req.options = EXTBOPT_ACTMODIFIER;
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(join)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(join)(int module_unload)
{
return MOD_SUCCESS;
}
/** This ban that affects JOINs only */
int extban_modej_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *sub_ban;
if (type != BANCHK_JOIN)
return 0;
sub_ban = banin + 3;
return ban_check_mask(sptr, chptr, sub_ban, type, 0);
}
+78
View File
@@ -0,0 +1,78 @@
/*
* Extended ban that affects nick-changes only (+b ~n)
* (C) Copyright 2003-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(nickchange)
= {
"chanmodes/extbans/nickchange",
"$Id$",
"ExtBan ~n - prevent nick-changes only",
"3.2-b8-1",
NULL
};
/* Forward declarations */
int extban_nickchange_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(nickchange)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'n';
req.is_ok = extban_is_ok_nuh_extban;
req.conv_param = extban_conv_param_nuh_or_extban;
req.is_banned = extban_nickchange_is_banned;
req.options = EXTBOPT_ACTMODIFIER;
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(nickchange)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(nickchange)(int module_unload)
{
return MOD_SUCCESS;
}
/** This ban that affects nick-changes only */
int extban_nickchange_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *sub_ban;
if (type != BANCHK_NICK)
return 0;
sub_ban = banin + 3;
return ban_check_mask(sptr, chptr, sub_ban, type, 0);
}
+77
View File
@@ -0,0 +1,77 @@
/*
* Extended ban that affects messages/notices only (+b ~q)
* (C) Copyright 2003-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(quiet)
= {
"chanmodes/extbans/quiet",
"$Id$",
"ExtBan ~q - prevent messages only (quiet)",
"3.2-b8-1",
NULL
};
/* Forward declarations */
int extban_quiet_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(quiet)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'q';
req.is_ok = extban_is_ok_nuh_extban;
req.conv_param = extban_conv_param_nuh_or_extban;
req.is_banned = extban_quiet_is_banned;
req.options = EXTBOPT_ACTMODIFIER;
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(quiet)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(quiet)(int module_unload)
{
return MOD_SUCCESS;
}
/** This ban that affects messages/notices only */
int extban_quiet_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *sub_ban;
if (type != BANCHK_MSG)
return 0;
sub_ban = banin + 3;
return ban_check_mask(sptr, chptr, sub_ban, type, 0);
}
+94
View File
@@ -0,0 +1,94 @@
/*
* Extended ban to ban based on real name / gecos field (+b ~r)
* (C) Copyright 2003-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(realname)
= {
"chanmodes/extbans/realname",
"$Id$",
"ExtBan ~r - Ban based on realname/gecos field",
"3.2-b8-1",
NULL
};
/* Forward declarations */
char *extban_realname_conv_param(char *para);
int extban_realname_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(realname)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'r';
req.is_ok = NULL;
req.conv_param = extban_realname_conv_param;
req.is_banned = extban_realname_is_banned;
req.options = EXTBOPT_CHSVSMODE|EXTBOPT_INVEX;
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(realname)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(realname)(int module_unload)
{
return MOD_SUCCESS;
}
/** Realname bans - conv_param */
char *extban_realname_conv_param(char *para)
{
static char retbuf[REALLEN + 8];
char *mask;
strlcpy(retbuf, para, sizeof(retbuf));
mask = retbuf+3;
if (strlen(mask) > REALLEN + 3)
mask[REALLEN + 3] = '\0';
if (*mask == '~')
*mask = '?'; /* Is this good? No ;) */
return retbuf;
}
int extban_realname_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin+3;
if (!match_esc(ban, sptr->info))
return 1;
return 0;
}
+88
View File
@@ -0,0 +1,88 @@
/*
* Extended ban type: ban (or exempt or invex) registered nick (~b ~R:xyz)
* (C) Copyright 2003-.. Bram Matthys (Syzop) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER(regnick)
= {
"chanmodes/extbans/regnick",
"$Id$",
"ExtBan ~R - Ban/exempt specific nick, but only if registered",
"3.2-b8-1",
NULL
};
/* Forward declarations */
char *extban_regnick_conv_param(char *para);
int extban_regnick_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type);
/** Called upon module init */
DLLFUNC int MOD_INIT(regnick)(ModuleInfo *modinfo)
{
ExtbanInfo req;
req.flag = 'R';
req.is_ok = NULL;
req.conv_param = extban_regnick_conv_param;
req.is_banned = extban_regnick_is_banned;
req.options = EXTBOPT_INVEX;
if (!ExtbanAdd(modinfo->handle, req))
{
config_error("could not register extended ban type");
return MOD_FAILED;
}
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
/** Called upon module load */
DLLFUNC int MOD_LOAD(regnick)(int module_load)
{
return MOD_SUCCESS;
}
/** Called upon unload */
DLLFUNC int MOD_UNLOAD(regnick)(int module_unload)
{
return MOD_SUCCESS;
}
/** Registered user ban */
char *extban_regnick_conv_param(char *para)
{
static char retbuf[NICKLEN + 4];
strlcpy(retbuf, para, sizeof(retbuf));
if (do_nick_name(retbuf+3) == 0)
return NULL;
return retbuf;
}
int extban_regnick_is_banned(aClient *sptr, aChannel *chptr, char *banin, int type)
{
char *ban = banin+3;
if (IsRegNick(sptr) && !strcasecmp(ban, sptr->name))
return 1;
return 0;
}