summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_cban.cpp52
-rw-r--r--src/modules/m_rline.cpp33
-rw-r--r--src/modules/m_shun.cpp86
-rw-r--r--src/modules/m_svshold.cpp46
4 files changed, 79 insertions, 138 deletions
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 93a3d5b5a..92f97158e 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -74,7 +74,7 @@ class CBanFactory : public XLineFactory
public:
CBanFactory() : XLineFactory("CBAN") { }
- /** Generate a shun
+ /** Generate a CBAN
*/
XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask)
{
@@ -112,56 +112,41 @@ class CommandCBan : public Command
else
{
user->WriteServ("NOTICE %s :*** CBan %s not found in list, try /stats C.",user->nick.c_str(),parameters[0].c_str());
+ return CMD_FAILURE;
}
-
- return CMD_SUCCESS;
}
- else if (parameters.size() >= 2)
+ else
{
// Adding - XXX todo make this respect <insane> tag perhaps..
long duration = ServerInstance->Duration(parameters[1]);
- CBan *r = NULL;
const char *reason = (parameters.size() > 2) ? parameters[2].c_str() : "No reason supplied";
+ CBan* r = new CBan(ServerInstance->Time(), duration, user->nick.c_str(), reason, parameters[0].c_str());
- try
- {
- r = new CBan(ServerInstance->Time(), duration, user->nick.c_str(), reason, parameters[0].c_str());
- }
- catch (...)
- {
- ; // Do nothing. If we get here, the regex was fucked up, and they already got told it fucked up.
- }
-
- if (r)
+ if (ServerInstance->XLines->AddLine(r, user))
{
- if (ServerInstance->XLines->AddLine(r, user))
+ if (!duration)
{
- if (!duration)
- {
- ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent CBan for %s: %s", user->nick.c_str(), parameters[0].c_str(), reason);
- }
- else
- {
- time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), reason);
- }
-
- ServerInstance->XLines->ApplyLines();
+ ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent CBan for %s: %s", user->nick.c_str(), parameters[0].c_str(), reason);
}
else
{
- delete r;
- user->WriteServ("NOTICE %s :*** CBan for %s already exists", user->nick.c_str(), parameters[0].c_str());
+ time_t c_requires_crap = duration + ServerInstance->Time();
+ ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), reason);
}
}
+ else
+ {
+ delete r;
+ user->WriteServ("NOTICE %s :*** CBan for %s already exists", user->nick.c_str(), parameters[0].c_str());
+ return CMD_FAILURE;
+ }
}
-
- return CMD_FAILURE;
+ return CMD_SUCCESS;
}
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- return ROUTE_BROADCAST;
+ return ROUTE_LOCALONLY;
}
};
@@ -203,9 +188,8 @@ class ModuleCBan : public Module
{
// Channel is banned.
user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick.c_str(), cname, rl->reason.c_str());
- ServerInstance->SNO->WriteToSnoMask('a', "%s tried to join %s which is CBANed (%s)",
+ ServerInstance->SNO->WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)",
user->nick.c_str(), cname, rl->reason.c_str());
- ServerInstance->PI->SendSNONotice("A", user->nick + " tried to join " + std::string(cname) + " which is CBANed (" + rl->reason + ")");
return MOD_RES_DENY;
}
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index 06c852938..28fa891b6 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -27,7 +27,7 @@
#include "xline.h"
static bool ZlineOnMatch = false;
-static std::vector<ZLine *> background_zlines;
+static bool added_zline = false;
class RLine : public XLine
{
@@ -75,8 +75,17 @@ class RLine : public XLine
void Apply(User* u)
{
- if (ZlineOnMatch) {
- background_zlines.push_back(new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString()));
+ if (ZlineOnMatch)
+ {
+ ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString());
+ if (ServerInstance->XLines->AddLine(zl, NULL))
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on *@%s%s%s: %s",
+ zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? ServerInstance->TimeString(zl->expiry).c_str() : "", zl->reason.c_str());
+ added_zline = true;
+ }
+ else
+ delete zl;
}
DefaultApply(u, "R", false);
}
@@ -199,7 +208,7 @@ class CommandRLine : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- return ROUTE_BROADCAST;
+ return ROUTE_LOCALONLY;
}
};
@@ -254,9 +263,6 @@ class ModuleRLine : public Module
{
ConfigReader Conf;
- if (!Conf.ReadFlag("rline", "zlineonmatch", 0) && ZlineOnMatch)
- background_zlines.clear();
-
MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0);
ZlineOnMatch = Conf.ReadFlag("rline", "zlineonmatch", 0);
std::string newrxengine = Conf.ReadValue("rline", "engine", 0);
@@ -299,18 +305,11 @@ class ModuleRLine : public Module
virtual void OnBackgroundTimer(time_t curtime)
{
- if (!ZlineOnMatch) return;
- for (std::vector<ZLine *>::iterator i = background_zlines.begin(); i != background_zlines.end(); i++)
+ if (added_zline)
{
- ZLine *zl = *i;
- if (ServerInstance->XLines->AddLine(zl,NULL))
- {
- ServerInstance->SNO->WriteToSnoMask('x',"Z-line added due to R-line match on *@%s%s%s: %s",
- zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? ServerInstance->TimeString(zl->expiry).c_str() : "", zl->reason.c_str());
- ServerInstance->XLines->ApplyLines();
- }
+ added_zline = false;
+ ServerInstance->XLines->ApplyLines();
}
- background_zlines.clear();
}
};
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 391f9a187..fe1c41162 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -59,11 +59,6 @@ public:
return false;
}
- void Apply(User *u)
- {
- }
-
-
void DisplayExpiry()
{
ServerInstance->SNO->WriteToSnoMask('x',"Removing expired shun %s (set by %s %ld seconds ago)",
@@ -89,6 +84,11 @@ class ShunFactory : public XLineFactory
{
return new Shun(set_time, duration, source, reason, xline_specific_mask);
}
+
+ bool AutoApplyToUserList(XLine *x)
+ {
+ return false;
+ }
};
//typedef std::vector<Shun> shunlist;
@@ -121,11 +121,10 @@ class CommandShun : public Command
else
{
user->WriteServ("NOTICE %s :*** Shun %s not found in list, try /stats H.",user->nick.c_str(),target.c_str());
+ return CMD_FAILURE;
}
-
- return CMD_SUCCESS;
}
- else if (parameters.size() >= 2)
+ else
{
// Adding - XXX todo make this respect <insane> tag perhaps..
long duration;
@@ -140,49 +139,35 @@ class CommandShun : public Command
duration = 0;
expr = parameters[1];
}
- Shun *r = NULL;
- try
- {
- r = new Shun(ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str());
- }
- catch (...)
+ Shun* r = new Shun(ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str());
+ if (ServerInstance->XLines->AddLine(r, user))
{
- ; // Do nothing. If we get here, the regex was fucked up, and they already got told it fucked up.
- }
-
- if (r)
- {
- if (ServerInstance->XLines->AddLine(r, user))
+ if (!duration)
{
- if (!duration)
- {
- ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent SHUN for %s: %s",
- user->nick.c_str(), target.c_str(), expr.c_str());
- }
- else
- {
- time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s",
- user->nick.c_str(), target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), expr.c_str());
- }
-
- ServerInstance->XLines->ApplyLines();
+ ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent SHUN for %s: %s",
+ user->nick.c_str(), target.c_str(), expr.c_str());
}
else
{
- delete r;
- user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), expr.c_str());
+ time_t c_requires_crap = duration + ServerInstance->Time();
+ ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s",
+ user->nick.c_str(), target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), expr.c_str());
}
}
+ else
+ {
+ delete r;
+ user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), expr.c_str());
+ return CMD_FAILURE;
+ }
}
-
- return CMD_FAILURE;
+ return CMD_SUCCESS;
}
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- return ROUTE_BROADCAST;
+ return ROUTE_LOCALONLY;
}
};
@@ -200,8 +185,8 @@ class ModuleShun : public Module
ServerInstance->XLines->RegisterFactory(&f);
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnStats, I_OnPreCommand, I_OnUserConnect, I_OnRehash };
- ServerInstance->Modules->Attach(eventlist, this, 4);
+ Implementation eventlist[] = { I_OnStats, I_OnPreCommand, I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 3);
OnRehash(NULL);
}
@@ -235,8 +220,6 @@ class ModuleShun : public Module
cmds = "PING PONG QUIT";
ShunEnabledCommands.clear();
- NotifyOfShun = true;
- affectopers = false;
std::stringstream dcmds(cmds);
std::string thiscmd;
@@ -250,21 +233,6 @@ class ModuleShun : public Module
affectopers = MyConf.ReadFlag("shun", "affectopers", "no", 0);
}
- virtual void OnUserConnect(LocalUser* user)
- {
- if (!IS_LOCAL(user))
- return;
-
- // Apply lines on user connect
- XLine *rl = ServerInstance->XLines->MatchesLine("SHUN", user);
-
- if (rl)
- {
- // Bang. :P
- rl->Apply(user);
- }
- }
-
virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser* user, bool validated, const std::string &original_line)
{
if (validated)
@@ -296,10 +264,10 @@ class ModuleShun : public Module
/* Allow QUIT but dont show any quit message */
parameters.clear();
}
- else if (command == "PART")
+ else if ((command == "PART") && (parameters.size() > 1))
{
/* same for PART */
- parameters[1] = "";
+ parameters[1].clear();
}
/* if we're here, allow the command. */
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index a38776d8d..37288a322 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -81,6 +81,11 @@ class SVSHoldFactory : public XLineFactory
{
return new SVSHold(set_time, duration, source, reason, xline_specific_mask);
}
+
+ bool AutoApplyToUserList(XLine *x)
+ {
+ return false;
+ }
};
/** Handle /SVSHold
@@ -115,45 +120,30 @@ class CommandSvshold : public Command
{
user->WriteServ("NOTICE %s :*** SVSHOLD %s not found in list, try /stats S.",user->nick.c_str(),parameters[0].c_str());
}
-
- return CMD_SUCCESS;
}
- else if (parameters.size() >= 2)
+ else
{
// Adding - XXX todo make this respect <insane> tag perhaps..
long duration = ServerInstance->Duration(parameters[1]);
- SVSHold *r = NULL;
+ SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
- try
- {
- r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
- }
- catch (...)
+ if (ServerInstance->XLines->AddLine(r, user))
{
- ; // Do nothing.
- }
-
- if (r)
- {
- if (ServerInstance->XLines->AddLine(r, user))
+ if (!duration)
{
- if (!duration)
- {
- ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent SVSHOLD for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
- }
- else
- {
- time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
- }
-
- ServerInstance->XLines->ApplyLines();
+ ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent SVSHOLD for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
}
else
{
- delete r;
+ time_t c_requires_crap = duration + ServerInstance->Time();
+ ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
}
}
+ else
+ {
+ delete r;
+ return CMD_FAILURE;
+ }
}
return CMD_SUCCESS;
@@ -161,7 +151,7 @@ class CommandSvshold : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- return ROUTE_BROADCAST;
+ return ROUTE_LOCALONLY;
}
};