1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 05:53:12 +02:00

Removed SZLine. Instead, have AKILL determine whether or not a ZLINE should be set.

This commit is contained in:
Adam
2011-08-13 14:24:08 -04:00
parent 2b5d9f349f
commit 4a7ba7ef4c
8 changed files with 41 additions and 242 deletions
+2 -4
View File
@@ -68,7 +68,7 @@ operserv
/*
* These define the default expiration times for, respectively, AKILLs, CHANKILLs, SNLINEs,
* SQLINEs, and SZLINEs.
* and SQLINEs.
*/
autokillexpiry = 30d
chankillexpiry = 30d
@@ -110,7 +110,6 @@ operserv
* - akillexpire: An AKILL has expired
* - snlineexpire: An SNLINE has expired
* - sqlineexpire: An SQLINE has expired
* - szlineexpire: An SZLINE has expired
* - exceptionexpire: A session exception has expired
*
* This directive is optional, if left blank, there will be no notifications.
@@ -572,14 +571,13 @@ command { service = "OperServ"; name = "SVSNICK"; command = "operserv/svsnick";
/*
* os_sxline
*
* Provides the operserv/snline, operserv/sqline, and operserv/szline commands.
* Provides the operserv/snline and operserv/sqline commands.
*
* Used to ban different things such as realnames, nicknames, and IPs.
*/
module { name = "os_sxline" }
command { service = "OperServ"; name = "SNLINE"; command = "operserv/snline"; permission = "operserv/snline"; }
command { service = "OperServ"; name = "SQLINE"; command = "operserv/sqline"; permission = "operserv/sqline"; }
command { service = "OperServ"; name = "SZLINE"; command = "operserv/szline"; permission = "operserv/szline"; }
/*
* os_update
-4
View File
@@ -576,8 +576,6 @@ class CoreExport ServerConfig
time_t SNLineExpiry;
/* Default expiry time for SQLines */
time_t SQLineExpiry;
/* Default expiry time for SZLine */
time_t SZLineExpiry;
/* Actually akill the user when the akill is added */
bool AkillOnAdd;
/* Kill users on SNLine */
@@ -594,8 +592,6 @@ class CoreExport ServerConfig
bool WallSNLineExpire;
/* Send a WALLOPS/GLOBOPS when SQLines expire */
bool WallSQLineExpire;
/* Send a WALLOPS/GLOBOPS when SZLines expire */
bool WallSZLineExpire;
/* Send a WALLOPS/GLOBOPS when exceptions expire */
bool WallExceptionExpire;
/* Add the akillers nick to the akill reason */
+1
View File
@@ -27,6 +27,7 @@ class CoreExport XLine
Anope::string GetNick() const;
Anope::string GetUser() const;
Anope::string GetHost() const;
sockaddrs GetIP() const;
};
class CoreExport XLineManager : public Service
+2 -22
View File
@@ -34,7 +34,7 @@ static int stats_count_servers(Server *s)
class CommandOSStats : public Command
{
service_reference<XLineManager> akills, snlines, sqlines, szlines;
service_reference<XLineManager> akills, snlines, sqlines;
private:
void DoStatsAkill(CommandSource &source)
{
@@ -99,26 +99,6 @@ class CommandOSStats : public Command
else
source.Reply(_("Default SQLINE expiry time: \002No expiration\002"));
}
if (ircd->szline && szlines)
{
/* SZLINEs */
source.Reply(_("Current number of SZLINEs: \002%d\002"), szlines->GetCount());
timeout = Config->SZLineExpiry + 59;
if (timeout >= 172800)
source.Reply(_("Default SZLINE expiry time: \002%d days\002"), timeout / 86400);
else if (timeout >= 86400)
source.Reply(_("Default SZLINE expiry time: \0021 day\002"));
else if (timeout >= 7200)
source.Reply(_("Default SZLINE expiry time: \002%d hours\002"), timeout / 3600);
else if (timeout >= 3600)
source.Reply(_("Default SZLINE expiry time: \0021 hour\002"));
else if (timeout >= 120)
source.Reply(_("Default SZLINE expiry time: \002%d minutes\002"), timeout / 60);
else if (timeout >= 60)
source.Reply(_("Default SZLINE expiry time: \0021 minute\002"));
else
source.Reply(_("Default SZLINE expiry time: \002No expiration\002"));
}
return;
}
@@ -158,7 +138,7 @@ class CommandOSStats : public Command
public:
CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1),
akills("xlinemanager/sgline"), snlines("xlinemanager/snline"), sqlines("xlinemanager/sqline"), szlines("xlinemanager/szline")
akills("xlinemanager/sgline"), snlines("xlinemanager/snline"), sqlines("xlinemanager/sqline")
{
this->SetDesc(_("Show status of Services and network"));
this->SetSyntax(_("[AKILL | ALL | RESET | UPLINK]"));
+1 -157
View File
@@ -633,168 +633,14 @@ class CommandOSSQLine : public CommandOSSXLineBase
}
};
class CommandOSSZLine : public CommandOSSXLineBase
{
XLineManager *xlm()
{
return this->szlines;
}
void OnAdd(CommandSource &source, const std::vector<Anope::string> &params)
{
if (!this->xlm())
return;
User *u = source.u;
unsigned last_param = 2;
Anope::string expiry, mask;
time_t expires;
mask = params.size() > 1 ? params[1] : "";
if (!mask.empty() && mask[0] == '+')
{
expiry = mask;
mask = params.size() > 2 ? params[2] : "";
last_param = 3;
}
expires = !expiry.empty() ? dotime(expiry) : Config->SZLineExpiry;
/* If the expiry given does not contain a final letter, it's in days,
* said the doc. Ah well.
*/
if (!expiry.empty() && isdigit(expiry[expiry.length() - 1]))
expires *= 86400;
/* Do not allow less than a minute expiry time */
if (expires && expires < 60)
{
source.Reply(BAD_EXPIRY_TIME);
return;
}
else if (expires > 0)
expires += Anope::CurTime;
if (params.size() <= last_param)
{
this->OnSyntaxError(source, "ADD");
return;
}
Anope::string reason = params[last_param];
if (last_param == 2 && params.size() > 3)
reason += " " + params[3];
if (!mask.empty() && !reason.empty())
{
std::pair<int, XLine *> canAdd = this->szlines->CanAdd(mask, expires);
if (mask.find('!') != Anope::string::npos || mask.find('@') != Anope::string::npos)
source.Reply(_("You can only add IP masks to the SZLINE list."));
else if (mask.find_first_not_of("*?") == Anope::string::npos)
source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str());
else if (canAdd.first == 1)
source.Reply(_("\002%s\002 already exists on the SZLINE list."), canAdd.second->Mask.c_str());
else if (canAdd.first == 2)
source.Reply(_("Expiry time of \002%s\002 changed."), canAdd.second->Mask.c_str());
else if (canAdd.first == 3)
source.Reply(_("\002%s\002 is already covered by %s."), mask.c_str(), canAdd.second->Mask.c_str());
else
{
User *user = finduser(mask);
if (user && user->ip())
mask = user->ip.addr();
unsigned int affected = 0;
for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (it->second->ip() && Anope::Match(it->second->ip.addr(), mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
if (percent > 95)
{
source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str());
Log(LOG_ADMIN, u, this) << "tried to SZLine " << percent << "% of the network (" << affected << " users)";
return;
}
XLine *x = this->szlines->Add(mask, u->nick, expires, reason);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, this->xlm()));
if (MOD_RESULT == EVENT_STOP)
{
delete x;
return;
}
source.Reply(_("\002%s\002 added to the SZLINE 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 << "%)]";
if (readonly)
source.Reply(READ_ONLY_MODE);
}
}
else
this->OnSyntaxError(source, "ADD");
return;
}
service_reference<XLineManager> szlines;
public:
CommandOSSZLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/szline"), szlines("xlinemanager/szline")
{
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Allows Services operators to manipulate the SZLINE list. If\n"
"a user with an IP matching an SZLINE mask attempts to \n"
"connect, Services will not allow it to pursue his IRC\n"
"session (and this, whether the IP has a PTR RR or not).\n"
" \n"));
source.Reply(_("\002SZLINE ADD\002 adds the given (nick's) IP mask to the SZLINE\n"
"list for the given reason (which \002must\002 be given).\n"
"\037expiry\037 is specified as an integer followed by one of \037d\037 \n"
"(days), \037h\037 (hours), or \037m\037 (minutes). Combinations (such as \n"
"\0371h30m\037) are not permitted. If a unit specifier is not \n"
"included, the default is days (so \037+30\037 by itself means 30 \n"
"days). To add an SZLINE which does not expire, use \037+0\037. If the\n"
"realname mask to be added starts with a \037+\037, an expiry time must\n"
"be given, even if it is the same as the default. The\n"
"current SZLINE default expiry time can be found with the\n"
"\002STATS AKILL\002 command.\n"));
source.Reply(_(" \n"
"The \002SZLINE DEL\002 command removes the given mask from the\n"
"SZLINE list if it is present. If a list of entry numbers is \n"
"given, those entries are deleted. (See the example for LIST \n"
"below.)\n"
" \n"
"The \002SZLINE LIST\002 command displays the SZLINE list.\n"
"If a wildcard mask is given, only those entries matching the\n"
"mask are displayed. If a list of entry numbers is given,\n"
"only those entries are shown; for example:\n"
" \002SZLINE LIST 2-5,7-9\002\n"
" Lists SZLINE entries numbered 2 through 5 and 7 \n"
" through 9.\n"
" \n"
"\002SZLINE VIEW\002 is a more verbose version of \002SZLINE LIST\002, and \n"
"will show who added an SZLINE, the date it was added, and when\n"
"it expires, as well as the IP mask and reason.\n"
" \n"
"\002SZLINE CLEAR\002 clears all entries of the SZLINE list."));
return true;
}
};
class OSSXLine : public Module
{
CommandOSSNLine commandossnline;
CommandOSSQLine commandossqline;
CommandOSSZLine commandosszline;
public:
OSSXLine(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandossnline(this), commandossqline(this), commandosszline(this)
commandossnline(this), commandossqline(this)
{
this->SetAuthor("Anope");
@@ -802,8 +648,6 @@ class OSSXLine : public Module
ModuleManager::RegisterService(&commandossnline);
if (ircd && ircd->sqline)
ModuleManager::RegisterService(&commandossqline);
if (ircd && ircd->szline)
ModuleManager::RegisterService(&commandosszline);
}
};
+26 -50
View File
@@ -34,14 +34,26 @@ class SGLineManager : public XLineManager
void Del(XLine *x)
{
ircdproto->SendAkillDel(x);
try
{
if (!ircd->szline)
throw SocketException("SZLine is not supported");
else if (x->GetUser() != "*")
throw SocketException("Can not ZLine a username");
x->GetIP();
ircdproto->SendSZLineDel(x);
}
catch (const SocketException &)
{
ircdproto->SendAkillDel(x);
}
}
void OnMatch(User *u, XLine *x)
{
if (u)
u->Kill(Config->OperServ, x->Reason);
ircdproto->SendAkill(u, x);
this->Send(u, x);
}
void OnExpire(XLine *x)
@@ -52,52 +64,19 @@ class SGLineManager : public XLineManager
void Send(User *u, XLine *x)
{
ircdproto->SendAkill(u, x);
}
};
class SZLineManager : public XLineManager
{
public:
SZLineManager(Module *creator) : XLineManager(creator, "xlinemanager/szline", 'Z') { }
XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason)
{
XLine *x = new XLine(mask, creator, expires, reason);
this->AddXLine(x);
if (UplinkSock)
this->Send(NULL, x);
return x;
}
void Del(XLine *x)
{
ircdproto->SendSZLineDel(x);
}
void OnMatch(User *u, XLine *x)
{
if (u)
try
{
Anope::string reason = "Z-Lined: " + x->Reason;
u->Kill(Config->OperServ, reason);
if (!ircd->szline)
throw SocketException("SZLine is not supported");
else if (x->GetUser() != "*")
throw SocketException("Can not ZLine a username");
x->GetIP();
ircdproto->SendSZLine(u, x);
}
catch (const SocketException &)
{
ircdproto->SendAkill(u, x);
}
ircdproto->SendSZLine(u, x);
}
void OnExpire(XLine *x)
{
if (Config->WallSZLineExpire)
ircdproto->SendGlobops(OperServ, "SZLINE on \2%s\2 has expired", x->Mask.c_str());
}
void Send(User *u, XLine *x)
{
ircdproto->SendSZLine(u, x);
}
};
@@ -274,13 +253,12 @@ class SNLineManager : public XLineManager
class OperServCore : public Module
{
SGLineManager sglines;
SZLineManager szlines;
SQLineManager sqlines;
SNLineManager snlines;
public:
OperServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
sglines(this), szlines(this), sqlines(this), snlines(this)
sglines(this), sqlines(this), snlines(this)
{
this->SetAuthor("Anope");
@@ -292,13 +270,11 @@ class OperServCore : public Module
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
ModuleManager::RegisterService(&sglines);
ModuleManager::RegisterService(&szlines);
ModuleManager::RegisterService(&sqlines);
ModuleManager::RegisterService(&snlines);
/* Yes, these are in this order for a reason. Most violent->least violent. */
XLineManager::RegisterXLineManager(&sglines);
XLineManager::RegisterXLineManager(&szlines);
XLineManager::RegisterXLineManager(&sqlines);
XLineManager::RegisterXLineManager(&snlines);
}
+2 -5
View File
@@ -141,7 +141,7 @@ ServerConfig::ServerConfig() : config_data(), NSDefFlags(NickCoreFlagStrings), C
}
this->WallOper = this->WallBadOS = this->WallAkillExpire = this->WallSNLineExpire = this->WallSQLineExpire =
this->WallSZLineExpire = this->WallExceptionExpire = false;
this->WallExceptionExpire = false;
if (!OSNotifications.empty())
{
spacesepstream notifications(OSNotifications);
@@ -158,8 +158,6 @@ ServerConfig::ServerConfig() : config_data(), NSDefFlags(NickCoreFlagStrings), C
this->WallSNLineExpire = true;
else if (notice.equals_ci("sqlineexpire"))
this->WallSQLineExpire = true;
else if (notice.equals_ci("szlineexpire"))
this->WallSZLineExpire = true;
else if (notice.equals_ci("exceptionexpire"))
this->WallExceptionExpire = true;
}
@@ -477,7 +475,7 @@ bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anop
{
if (value.equals_ci("description") && data.GetValue().empty())
throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when OperServ is enabled!");
else if (value.equals_ci("autokillexpiry") || value.equals_ci("chankillexpiry") || value.equals_ci("snlineexpiry") || value.equals_ci("szlineexpiry") || value.equals_ci("sqlineexpiry"))
else if (value.equals_ci("autokillexpiry") || value.equals_ci("chankillexpiry") || value.equals_ci("snlineexpiry") || value.equals_ci("sqlineexpiry"))
return ValidateNotZero(config, tag, value, data);
else if (value.equals_ci("maxsessionlimit") || value.equals_ci("exceptionexpiry"))
return ValidateLimitSessions(config, tag, value, data);
@@ -1211,7 +1209,6 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"operserv", "chankillexpiry", "0", new ValueContainerTime(&conf->ChankillExpiry), DT_TIME, ValidateOperServ},
{"operserv", "snlineexpiry", "0", new ValueContainerTime(&conf->SNLineExpiry), DT_TIME, ValidateOperServ},
{"operserv", "sqlineexpiry", "0", new ValueContainerTime(&conf->SQLineExpiry), DT_TIME, ValidateOperServ},
{"operserv", "szlineexpiry", "0", new ValueContainerTime(&conf->SZLineExpiry), DT_TIME, ValidateOperServ},
{"operserv", "akillonadd", "no", new ValueContainerBool(&conf->AkillOnAdd), DT_BOOLEAN, NoValidation},
{"operserv", "killonsnline", "no", new ValueContainerBool(&conf->KillonSNline), DT_BOOLEAN, NoValidation},
{"operserv", "killonsqline", "no", new ValueContainerBool(&conf->KillonSQline), DT_BOOLEAN, NoValidation},
+7
View File
@@ -59,6 +59,13 @@ Anope::string XLine::GetHost() const
return this->Mask.substr(host_t + 1);
}
sockaddrs XLine::GetIP() const
{
sockaddrs addr;
addr.pton(this->GetHost().find(':') != Anope::string::npos ? AF_INET6 : AF_INET, this->GetHost());
return addr;
}
/** Constructor
*/
XLineManager::XLineManager(Module *creator, const Anope::string &xname, char t) : Service(creator, xname), type(t)