summaryrefslogtreecommitdiff
path: root/modules/commands
diff options
context:
space:
mode:
Diffstat (limited to 'modules/commands')
-rw-r--r--modules/commands/os_akill.cpp28
-rw-r--r--modules/commands/os_chankill.cpp3
-rw-r--r--modules/commands/os_defcon.cpp29
-rw-r--r--modules/commands/os_session.cpp4
-rw-r--r--modules/commands/os_sxline.cpp90
5 files changed, 115 insertions, 39 deletions
diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp
index 99aa60089..3b82fb5fb 100644
--- a/modules/commands/os_akill.cpp
+++ b/modules/commands/os_akill.cpp
@@ -208,7 +208,14 @@ class CommandOSAKill : public Command
if (Config->AddAkiller)
reason = "[" + u->nick + "] " + reason;
- XLine *x = akills->Add(mask, u->nick, expires, reason);
+ Anope::string id;
+ if (Config->AkillIds)
+ {
+ id = XLineManager::GenerateUID();
+ reason = reason + " (ID: " + id + ")";
+ }
+
+ XLine *x = new XLine(mask, u->nick, expires, reason, id);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, akills));
@@ -218,9 +225,13 @@ class CommandOSAKill : public Command
return;
}
+ akills->AddXLine(x);
+ if (Config->AkillOnAdd)
+ akills->Send(NULL, x);
+
source.Reply(_("\002%s\002 added to the AKILL list."), mask.c_str());
- Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]";
+ Log(LOG_ADMIN, u, this) << "on " << mask << " (" << x->Reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]";
if (readonly)
source.Reply(READ_ONLY_MODE);
@@ -266,8 +277,9 @@ class CommandOSAKill : public Command
FOREACH_MOD(I_OnDelXLine, OnDelXLine(u, x, akills));
+ source.Reply(_("\002%s\002 deleted from the AKILL list."), x->Mask.c_str());
AkillDelCallback::DoDel(source, x);
- source.Reply(_("\002%s\002 deleted from the AKILL list."), mask.c_str());
+
}
if (readonly)
@@ -299,7 +311,7 @@ class CommandOSAKill : public Command
{
XLine *x = akills->GetEntry(i);
- if (mask.empty() || mask.equals_ci(x->Mask) || Anope::Match(x->Mask, mask))
+ if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask))
{
if (!SentHeader)
{
@@ -344,7 +356,7 @@ class CommandOSAKill : public Command
{
XLine *x = akills->GetEntry(i);
- if (mask.empty() || mask.equals_ci(x->Mask) || Anope::Match(x->Mask, mask))
+ if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask))
{
if (!SentHeader)
{
@@ -377,9 +389,9 @@ class CommandOSAKill : public Command
{
this->SetDesc(_("Manipulate the AKILL list"));
this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037 \037reason\037"));
- this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
- this->SetSyntax(_("LIST [\037mask\037 | \037list\037]"));
- this->SetSyntax(_("VIEW [\037mask\037 | \037list\037]"));
+ this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037 | \037id\037}"));
+ this->SetSyntax(_("LIST [\037mask\037 | \037list\037 | \037id\037]"));
+ this->SetSyntax(_("VIEW [\037mask\037 | \037list\037 | \037id\037]"));
this->SetSyntax(_("CLEAR"));
}
diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp
index 53e7dfd9c..e6b69cb9f 100644
--- a/modules/commands/os_chankill.cpp
+++ b/modules/commands/os_chankill.cpp
@@ -80,7 +80,8 @@ class CommandOSChanKill : public Command
if (uc->user->server == Me || uc->user->HasMode(UMODE_OPER))
continue;
- akills->Add("*@" + uc->user->host, u->nick, expires, realreason);
+ XLine *x = new XLine("*@" + uc->user->host, u->nick, expires, realreason, XLineManager::GenerateUID());
+ akills->AddXLine(x);
akills->Check(uc->user);
}
diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp
index 4966f9e78..f97dfab92 100644
--- a/modules/commands/os_defcon.cpp
+++ b/modules/commands/os_defcon.cpp
@@ -424,9 +424,9 @@ class OSDefcon : public Module
if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills)
{
Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host;
- XLine *x = akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason);
- if (x)
- x->By = Config->OperServ;
+ XLine *x = new XLine("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID());
+ x->By = Config->OperServ;
+ akills->AddXLine(x);
}
if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS))
@@ -518,9 +518,9 @@ class OSDefcon : public Module
if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills)
{
Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host;
- XLine *x = akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason);
- if (x)
- x->By = Config->OperServ;
+ XLine x("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID());
+ x.By = Config->OperServ;
+ akills->Send(NULL, &x);
}
if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS))
{
@@ -528,23 +528,15 @@ class OSDefcon : public Module
return;
}
- if (!DConfig.sessionlimit)
- return;
-
- if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills)
- {
- Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host;
- XLine *x = akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, !DConfig.akillreason.empty() ? DConfig.akillreason : "DEFCON AKILL");
- if (x)
- x->By = Config->OperServ;
- }
-
if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS))
{
u->Kill(Config->OperServ, DConfig.akillreason);
return;
}
+ if (!DConfig.sessionlimit)
+ return;
+
Session *session = session_service->FindSession(u->host);
Exception *exception = session_service->FindException(u);
@@ -561,7 +553,8 @@ class OSDefcon : public Module
++session->hits;
if (akills && Config->MaxSessionKill && session->hits >= Config->MaxSessionKill)
{
- akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Defcon session limit exceeded");
+ XLine x("*@" + u->host, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Defcon session limit exceeded", XLineManager::GenerateUID());
+ akills->Send(NULL, &x);
ircdproto->SendGlobops(findbot(Config->OperServ), "[DEFCON] Added a temporary AKILL for \2*@%s\2 due to excessive connections", u->host.c_str());
}
}
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp
index a6a2d2396..edaf841d5 100644
--- a/modules/commands/os_session.cpp
+++ b/modules/commands/os_session.cpp
@@ -679,7 +679,9 @@ class OSSession : public Module
if (Config->MaxSessionKill && session->hits >= Config->MaxSessionKill && akills)
{
const Anope::string &akillmask = "*@" + u->host;
- akills->Add(akillmask, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Session limit exceeded");
+ XLine *x = new XLine(akillmask, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Session limit exceeded", XLineManager::GenerateUID());
+ akills->AddXLine(x);
+ akills->Send(NULL, x);
if (bi)
ircdproto->SendGlobops(bi, "Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask.c_str());
}
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp
index 80ad9db8c..56444383d 100644
--- a/modules/commands/os_sxline.cpp
+++ b/modules/commands/os_sxline.cpp
@@ -205,7 +205,7 @@ class CommandOSSXLineBase : public Command
{
XLine *x = this->xlm()->GetEntry(i);
- if (mask.empty() || mask.equals_ci(x->Mask) || Anope::Match(x->Mask, mask))
+ if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask))
{
if (!SentHeader)
{
@@ -249,7 +249,7 @@ class CommandOSSXLineBase : public Command
{
XLine *x = this->xlm()->GetEntry(i);
- if (mask.empty() || mask.equals_ci(x->Mask) || Anope::Match(x->Mask, mask))
+ if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask))
{
if (!SentHeader)
{
@@ -278,14 +278,9 @@ class CommandOSSXLineBase : public Command
return;
}
public:
- CommandOSSXLineBase(Module *creator, const Anope::string &cmd) : Command(creator, cmd, 1, 3)
+ CommandOSSXLineBase(Module *creator, const Anope::string &cmd) : Command(creator, cmd, 1, 4)
{
this->SetDesc(Anope::printf(_("Manipulate the %s list"), cmd.c_str()));
- this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037:\037reason\037"));
- this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
- this->SetSyntax(_("LIST [\037mask\037 | \037list\037]"));
- this->SetSyntax(_("VIEW [\037mask\037 | \037list\037]"));
- this->SetSyntax(_("CLEAR"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params)
@@ -410,7 +405,14 @@ class CommandOSSNLine : public CommandOSSXLineBase
if (Config->AddAkiller)
reason = "[" + u->nick + "] " + reason;
- XLine *x = this->xlm()->Add(mask, u->nick, expires, reason);
+ Anope::string id;
+ if (Config->AkillIds)
+ {
+ id = XLineManager::GenerateUID();
+ reason = reason + " (ID: " + id + ")";
+ }
+
+ XLine *x = new XLine(mask, u->nick, expires, reason, id);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, this->xlm()));
@@ -420,6 +422,21 @@ class CommandOSSNLine : public CommandOSSXLineBase
return;
}
+ this->xlm()->AddXLine(x);
+ if (Config->KillonSNline && !ircd->sglineenforce)
+ {
+ Anope::string rreason = "G-Lined: " + reason;
+
+ for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ {
+ User *user = it->second;
+ ++it;
+
+ if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask))
+ user->Kill(Config->ServerName, rreason);
+ }
+ }
+
source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), this->name.c_str());
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]";
@@ -438,6 +455,11 @@ class CommandOSSNLine : public CommandOSSXLineBase
public:
CommandOSSNLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/snline"), snlines("xlinemanager/snline")
{
+ this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037:\037reason\037"));
+ this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037 | \037id\037}"));
+ this->SetSyntax(_("LIST [\037mask\037 | \037list\037 | \037id\037]"));
+ this->SetSyntax(_("VIEW [\037mask\037 | \037list\037 | \037id\037]"));
+ this->SetSyntax(_("CLEAR"));
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
@@ -494,7 +516,7 @@ class CommandOSSQLine : public CommandOSSXLineBase
void OnAdd(CommandSource &source, const std::vector<Anope::string> &params)
{
- if (!this->xlm() ||! ircd->sqline)
+ if (!this->xlm() || !ircd->sqline)
{
source.Reply(_("Your IRCd does not support SQLINE"));
return;
@@ -563,7 +585,10 @@ class CommandOSSQLine : public CommandOSSXLineBase
return;
}
- XLine *x = this->sqlines->Add(mask, u->nick, expires, reason);
+ Anope::string id = XLineManager::GenerateUID();
+ reason = reason + " (ID: " + id + ")";
+
+ XLine *x = new XLine(mask, u->nick, expires, reason, id);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, this->xlm()));
@@ -573,6 +598,44 @@ class CommandOSSQLine : public CommandOSSXLineBase
return;
}
+ this->xlm()->AddXLine(x);
+ if (Config->KillonSQline)
+ {
+ Anope::string rreason = "Q-Lined: " + reason;
+
+ if (mask[0] == '#')
+ {
+ for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
+ {
+ Channel *c = cit->second;
+
+ if (!Anope::Match(c->name, mask))
+ continue;
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
+ {
+ UserContainer *uc = *it;
+ ++it;
+
+ if (uc->user->HasMode(UMODE_OPER) || uc->user->server == Me)
+ continue;
+ c->Kick(NULL, uc->user, "%s", reason.c_str());
+ }
+ }
+ }
+ else
+ {
+ for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ {
+ User *user = it->second;
+ ++it;
+
+ if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->nick, x->Mask))
+ user->Kill(Config->ServerName, rreason);
+ }
+ }
+ }
+ this->xlm()->Send(NULL, x);
+
source.Reply(_("\002%s\002 added to the SQLINE list."), mask.c_str());
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]";
@@ -591,6 +654,11 @@ class CommandOSSQLine : public CommandOSSXLineBase
public:
CommandOSSQLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/sqline"), sqlines("xlinemanager/sqline")
{
+ this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037 \037reason\037"));
+ this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037 | \037id\037}"));
+ this->SetSyntax(_("LIST [\037mask\037 | \037list\037 | \037id\037]"));
+ this->SetSyntax(_("VIEW [\037mask\037 | \037list\037 | \037id\037]"));
+ this->SetSyntax(_("CLEAR"));
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)