From b930f9a2fc7060738cabc00a5fe5845ec193d752 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Fri, 9 Dec 2005 20:21:37 +0000 Subject: [PATCH] - Added option to apply spamfilters to aliases as well (such as /MS, etc). To do so, you have to put 'spamfilter yes;' in every alias block you want to get filtered. This is so you can have for example /MS filtered (due to heavy spam), while keeping /NS and /CS unfiltered. Reported by Homer (#0002496). - The memoserv aliases (/MS and /MEMOSERV) now have spamfiltering enabled by default. --- Changes | 5 +++++ aliases/anope.conf | 4 ++-- aliases/auspice.conf | 4 ++-- aliases/cygnus.conf | 4 ++-- aliases/epona.conf | 4 ++-- aliases/generic.conf | 4 ++-- aliases/ircservices.conf | 4 ++-- doc/unreal32docs.html | 7 +++++-- include/struct.h | 1 + src/s_conf.c | 5 ++++- src/s_svs.c | 39 ++++++++++++++++++++++++++++++++------- 11 files changed, 59 insertions(+), 22 deletions(-) diff --git a/Changes b/Changes index 4a834ab83..29c92e0c5 100644 --- a/Changes +++ b/Changes @@ -932,3 +932,8 @@ - [CVS Only] Refixed name<->ip mapping check in new resolver, reported by Darko. - Reverting "Changed the way we build most of the .so's" feature, this caused m_*.so to be build incorrectly. So now back at normal compile speed :p. +- Added option to apply spamfilters to aliases as well (such as /MS, etc). To do so, + you have to put 'spamfilter yes;' in every alias block you want to get filtered. + This is so you can have for example /MS filtered (due to heavy spam), while keeping + /NS and /CS unfiltered. Reported by Homer (#0002496). +- The memoserv aliases (/MS and /MEMOSERV) now have spamfiltering enabled by default. diff --git a/aliases/anope.conf b/aliases/anope.conf index 7c2de6aa2..d7e48a3ec 100644 --- a/aliases/anope.conf +++ b/aliases/anope.conf @@ -4,8 +4,8 @@ alias nickserv { type services; }; alias ns { target nickserv; type services; }; alias chanserv { type services; }; alias cs { target chanserv; type services; }; -alias memoserv { type services; }; -alias ms { target memoserv; type services; }; +alias memoserv { type services; spamfilter yes; }; +alias ms { target memoserv; type services; spamfilter yes; }; alias operserv { type services; }; alias os { target operserv; type services; }; alias helpserv { type services; }; diff --git a/aliases/auspice.conf b/aliases/auspice.conf index 65bf4df86..58ae0fd36 100644 --- a/aliases/auspice.conf +++ b/aliases/auspice.conf @@ -21,8 +21,8 @@ alias helpserv { type services; }; alias hs { target helpserv; type services; }; alias hostserv { type services; }; alias ho { target hostserv; type services; }; -alias memoserv { type services; }; -alias ms { target memoserv; type services; }; +alias memoserv { type services; spamfilter yes; }; +alias ms { target memoserv; type services; spamfilter yes; }; alias nickserv { type services; }; alias ns { target nickserv; type services; }; alias operserv { type services; }; diff --git a/aliases/cygnus.conf b/aliases/cygnus.conf index 7a954da2a..4212f6f5d 100644 --- a/aliases/cygnus.conf +++ b/aliases/cygnus.conf @@ -4,8 +4,8 @@ alias nickserv { type services; }; alias ns { target nickserv; type services; }; alias chanserv { type services; }; alias cs { target chanserv; type services; }; -alias memoserv { type services; }; -alias ms { target memoserv; type services; }; +alias memoserv { type services; spamfilter yes; }; +alias ms { target memoserv; type services; spamfilter yes; }; alias rootserv { type services; }; alias rs { target rootserv; type services; }; diff --git a/aliases/epona.conf b/aliases/epona.conf index 0ffd5c6ed..dbe5157f4 100644 --- a/aliases/epona.conf +++ b/aliases/epona.conf @@ -4,8 +4,8 @@ alias nickserv { type services; }; alias ns { target nickserv; type services; }; alias chanserv { type services; }; alias cs { target chanserv; type services; }; -alias memoserv { type services; }; -alias ms { target memoserv; type services; }; +alias memoserv { type services; spamfilter yes; }; +alias ms { target memoserv; type services; spamfilter yes; }; alias operserv { type services; }; alias os { target operserv; type services; }; alias helpserv { type services; }; diff --git a/aliases/generic.conf b/aliases/generic.conf index f063939fa..819a73392 100644 --- a/aliases/generic.conf +++ b/aliases/generic.conf @@ -4,8 +4,8 @@ alias nickserv { type services; }; alias ns { target nickserv; type services; }; alias chanserv { type services; }; alias cs { target chanserv; type services; }; -alias memoserv { type services; }; -alias ms { target memoserv; type services; }; +alias memoserv { type services; spamfilter yes; }; +alias ms { target memoserv; type services; spamfilter yes; }; alias operserv { type services; }; alias os { target operserv; type services; }; alias helpserv { type services; }; diff --git a/aliases/ircservices.conf b/aliases/ircservices.conf index 2608312fe..486cc3a90 100644 --- a/aliases/ircservices.conf +++ b/aliases/ircservices.conf @@ -4,8 +4,8 @@ alias nickserv { type services; }; alias ns { target nickserv; type services; }; alias chanserv { type services; }; alias cs { target chanserv; type services; }; -alias memoserv { type services; }; -alias ms { target memoserv; type services; }; +alias memoserv { type services; spamfilter yes; }; +alias ms { target memoserv; type services; spamfilter yes; }; alias operserv { type services; }; alias os { target operserv; type services; }; alias helpserv { type services; }; diff --git a/doc/unreal32docs.html b/doc/unreal32docs.html index 3de78b4e5..789f53b1f 100644 --- a/doc/unreal32docs.html +++ b/doc/unreal32docs.html @@ -1973,6 +1973,7 @@ link hub.mynet.com { alias <name> { target <nick-to-forward-to>; type <type-of-alias>; + spamfilter <yes|no>; };

(Note: also see here about the standard alias files UnrealIRCd has)

The alias block [standard alias] allows you to forward a command to a user, @@ -1982,8 +1983,9 @@ alias <name> { forward to, alias::target can be left out. The alias::type specifies the type of alias, valid types are services (the user is on the services server), stats (the user is on the stats server), normal (the user is a normal user on - any server), and channel (the target is a channel name). The alias block also has another - purpose which is explained below.

+ any server), and channel (the target is a channel name). If alias::spamfilter (optional) + is set to 'yes', then the spamfilters will be checked (default is 'no').
+ The alias block also has another purpose which is explained below.

Syntax [command alias]:

 alias <name> {
@@ -1996,6 +1998,7 @@ alias <name> {
 		...
 	};
 	type command;
+	spamfilter <yes|no>;
 };

When the alias block is used in this format, it allows you a much broader range of usage. For example you can create aliases such as /identify. The alias:: diff --git a/include/struct.h b/include/struct.h index a80289fb8..9d33b7f82 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1314,6 +1314,7 @@ struct _configitem_alias { ConfigItem_alias_format *format; char *alias, *nick; AliasType type; + unsigned int spamfilter:1; }; struct _configitem_alias_format { diff --git a/src/s_conf.c b/src/s_conf.c index a27ebd94d..6c98bb2fa 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -7933,7 +7933,8 @@ int _conf_alias(ConfigFile *conf, ConfigEntry *ce) else if (!strcmp(cep->ce_vardata, "command")) alias->type = ALIAS_COMMAND; } - + else if (!strcmp(cep->ce_varname, "spamfilter")) + alias->spamfilter = config_checkval(cep->ce_vardata, CFG_YESNO); } if (BadPtr(alias->nick) && alias->type != ALIAS_COMMAND) { ircstrdup(alias->nick, alias->alias); @@ -8110,6 +8111,8 @@ int _test_alias(ConfigFile *conf, ConfigEntry *ce) { errors++; } } + else if (!strcmp(cep->ce_varname, "spamfilter")) + ; else { config_error_unknown(cep->ce_fileptr->cf_filename, cep->ce_varlinenum, "alias", cep->ce_varname); diff --git a/src/s_svs.c b/src/s_svs.c index 02354e194..585f4aa47 100644 --- a/src/s_svs.c +++ b/src/s_svs.c @@ -220,9 +220,12 @@ void strrangetok(char *in, char *out, char tok, short first, short last) { out[j] = 0; } -int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { - ConfigItem_alias *alias; - aClient *acptr; +int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) +{ +ConfigItem_alias *alias; +aClient *acptr; +int ret; + if (parc < 2 || *parv[1] == '\0') { sendto_one(sptr, err_str(ERR_NOTEXTTOSEND), me.name, parv[0]); @@ -238,9 +241,13 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { if (alias->type == ALIAS_SERVICES) { if (SERVICES_NAME && (acptr = find_person(alias->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_USERMSG, alias->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, alias->nick, SERVICES_NAME, parv[1]); + } else sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, parv[0], alias->nick); @@ -248,9 +255,13 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { else if (alias->type == ALIAS_STATS) { if (STATS_SERVER && (acptr = find_person(alias->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_USERMSG, alias->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, alias->nick, STATS_SERVER, parv[1]); + } else sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, parv[0], alias->nick); @@ -259,6 +270,8 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { { if ((acptr = find_person(alias->nick, NULL))) { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_USERMSG, alias->nick, 0)) < 0) + return ret; if (MyClient(acptr)) sendto_one(acptr, ":%s!%s@%s PRIVMSG %s :%s", parv[0], sptr->user->username, GetHost(sptr), @@ -279,6 +292,8 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { { if (!can_send(sptr, chptr, parv[1], 0)) { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_CHANMSG, chptr->chname, 0)) < 0) + return ret; sendto_channelprefix_butone_tok(sptr, sptr, chptr, PREFIX_ALL, @@ -355,27 +370,35 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { if (format->type == ALIAS_SERVICES) { if (SERVICES_NAME && (acptr = find_person(format->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, output, SPAMF_USERMSG, format->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, format->nick, SERVICES_NAME, output); - else + } else sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, parv[0], format->nick); } else if (format->type == ALIAS_STATS) { if (STATS_SERVER && (acptr = find_person(format->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, output, SPAMF_USERMSG, format->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, format->nick, STATS_SERVER, output); - else - sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, - parv[0], format->nick); + } else + sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, + parv[0], format->nick); } else if (format->type == ALIAS_NORMAL) { if ((acptr = find_person(format->nick, NULL))) { + if (alias->spamfilter && (ret = dospamfilter(sptr, output, SPAMF_USERMSG, format->nick, 0)) < 0) + return ret; if (MyClient(acptr)) sendto_one(acptr, ":%s!%s@%s PRIVMSG %s :%s", parv[0], sptr->user->username, IsHidden(sptr) ? sptr->user->virthost : sptr->user->realhost, @@ -396,6 +419,8 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { { if (!can_send(sptr, chptr, parv[1], 0)) { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_CHANMSG, chptr->chname, 0)) < 0) + return ret; sendto_channelprefix_butone_tok(sptr, sptr, chptr, PREFIX_ALL, MSG_PRIVATE,