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

Allow akill/szline/sqline to accept user names as a mask argument

This commit is contained in:
Adam
2010-11-14 17:05:35 -05:00
parent 3c9d4e9daf
commit 2e9a632e14
5 changed files with 69 additions and 10 deletions
+17 -1
View File
@@ -170,6 +170,22 @@ class CommandOSAKill : public Command
reason += " " + params[3];
if (!mask.empty() && !reason.empty())
{
User *user = finduser(mask);
if (user)
mask = "*@" + user->host;
unsigned int affected = 0;
for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
if (Anope::Match((*it)->GetIdent() + "@" + (*it)->host, mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
if (percent > 95)
{
u->SendMessage(OperServ, USERHOST_MASK_TOO_WIDE, mask.c_str());
Log(LOG_ADMIN, u, this) << "tried to akill " << percent << "% of the network (" << affected << " users)";
return MOD_CONT;
}
XLine *x = SGLine->Add(OperServ, u, mask, expires, reason);
if (!x)
@@ -207,7 +223,7 @@ class CommandOSAKill : public Command
buf = "expires in " + stringify(wall_expiry) + " " + s + (wall_expiry == 1 ? "" : "s");
}
ircdproto->SendGlobops(OperServ, "%s added an AKILL for %s (%s) (%s)", u->nick.c_str(), mask.c_str(), reason.c_str(), buf.c_str());
ircdproto->SendGlobops(OperServ, "%s added an AKILL for %s (%s) (%s) [affects %i user(s) (%.2f%%)]", u->nick.c_str(), mask.c_str(), reason.c_str(), buf.c_str(), affected, percent);
}
if (readonly)
+13 -1
View File
@@ -188,6 +188,18 @@ class CommandOSSNLine : public Command
unsigned masklen = mask.length();
if (mask[masklen - 1] == ' ')
mask.erase(masklen - 1);
unsigned int affected = 0;
for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
if (Anope::Match((*it)->realname, mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
if (percent > 95)
{
u->SendMessage(OperServ, USERHOST_MASK_TOO_WIDE, mask.c_str());
Log(LOG_ADMIN, u, this) << "tried to SNLine " << percent << "% of the network (" << affected << " users)";
return MOD_CONT;
}
XLine *x = SNLine->Add(OperServ, u, mask, expires, reason);
@@ -226,7 +238,7 @@ class CommandOSSNLine : public Command
buf = "expires in " + stringify(wall_expiry) + " " + s + (wall_expiry == 1 ? "" : "s");
}
ircdproto->SendGlobops(findbot(Config->s_OperServ), "%s added an SNLINE for %s (%s)", u->nick.c_str(), mask.c_str(), buf.c_str());
ircdproto->SendGlobops(findbot(Config->s_OperServ), "%s added an SNLINE for %s (%s) [affects %i user(s) (%.2f%%)]", u->nick.c_str(), mask.c_str(), buf.c_str(), affected, percent);
}
if (readonly)
+16 -1
View File
@@ -169,6 +169,21 @@ class CommandOSSQLine : public Command
reason += " " + params[3];
if (!mask.empty() && !reason.empty())
{
User *user = finduser(mask);
if (user)
mask = "*@" + user->host;
unsigned int affected = 0;
for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
if (Anope::Match((*it)->GetIdent() + "@" + (*it)->host, mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
if (percent > 95)
{
u->SendMessage(OperServ, USERHOST_MASK_TOO_WIDE, mask.c_str());
Log(LOG_ADMIN, u, this) << "tried to SQLine " << percent << "% of the network (" << affected << " users)";
return MOD_CONT;
}
XLine *x = SQLine->Add(OperServ, u, mask, expires, reason);
if (!x)
@@ -206,7 +221,7 @@ class CommandOSSQLine : public Command
buf = "expires in " + stringify(wall_expiry) + " " + s + (wall_expiry == 1 ? "" : "s");
}
ircdproto->SendGlobops(OperServ, "%s added an SQLINE for %s (%s)", u->nick.c_str(), mask.c_str(), buf.c_str());
ircdproto->SendGlobops(OperServ, "%s added an SQLINE for %s (%s) [affects %i user(s) (%.2f%%)]", u->nick.c_str(), mask.c_str(), buf.c_str(), affected, percent);
}
if (readonly)
+17 -1
View File
@@ -169,6 +169,22 @@ class CommandOSSZLine : public Command
reason += " " + params[3];
if (!mask.empty() && !reason.empty())
{
User *user = finduser(mask);
if (user && user->ip())
mask = user->ip.addr();
unsigned int affected = 0;
for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
if ((*it)->ip() && Anope::Match((*it)->ip.addr(), mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
if (percent > 95)
{
u->SendMessage(OperServ, USERHOST_MASK_TOO_WIDE, mask.c_str());
Log(LOG_ADMIN, u, this) << "tried to SZLine " << percent << "% of the network (" << affected << " users)";
return MOD_CONT;
}
XLine *x = SZLine->Add(OperServ, u, mask, expires, reason);
if (!x)
@@ -206,7 +222,7 @@ class CommandOSSZLine : public Command
buf = "expires in " + stringify(wall_expiry) + " " + s + (wall_expiry == 1 ? "" : "s");
}
ircdproto->SendGlobops(OperServ, "%s added an SZLINE for %s (%s)", u->nick.c_str(), mask.c_str(), buf.c_str());
ircdproto->SendGlobops(OperServ, "%s added an SZLINE for %s (%s) [affects %i user(s) (%.2f%%)]", u->nick.c_str(), mask.c_str(), buf.c_str(), affected, percent);
}
if (readonly)
+6 -6
View File
@@ -2094,7 +2094,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
/* OPER_SVSNICK_NEWNICK */
_("The nick %s is now being changed to %s."),
/* OPER_AKILL_SYNTAX */
_("AKILL {ADD | DEL | LIST | VIEW | CLEAR} [[+expiry] {mask | entry-list} [reason]]"),
_("AKILL {ADD | DEL | LIST | VIEW | CLEAR} [[+expiry] {\037nick\037 | mask | entry-list} [reason]]"),
/* OPER_AKILL_EXISTS */
_("%s already exists on the AKILL list."),
/* OPER_ALREADY_COVERED */
@@ -2157,7 +2157,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
/* OPER_SNLINE_CLEAR */
_("The SNLINE list has been cleared."),
/* OPER_SQLINE_SYNTAX */
_("SQLINE {ADD | DEL | LIST | VIEW | CLEAR} [[+expiry] {mask | entry-list} [reason]]"),
_("SQLINE {ADD | DEL | LIST | VIEW | CLEAR} [[+expiry] {\037nick\037 | mask | entry-list} [reason]]"),
/* OPER_SQLINE_CHANNELS_UNSUPPORTED */
_("Channel SQLINEs are not supported by your IRCd, so you can't use them."),
/* OPER_SQLINE_EXISTS */
@@ -2184,7 +2184,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
/* OPER_SQLINE_CLEAR */
_("The SQLINE list has been cleared."),
/* OPER_SZLINE_SYNTAX */
_("SZLINE {ADD | DEL | LIST | VIEW | CLEAR} [[+expiry] {mask | entry-list} [reason]]"),
_("SZLINE {ADD | DEL | LIST | VIEW | CLEAR} [[+expiry] {\037nick\037 | mask | entry-list} [reason]]"),
/* OPER_SZLINE_EXISTS */
_("%s already exists on the SZLINE list."),
/* OPER_SZLINE_ONLY_IPS */
@@ -4534,7 +4534,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
"types, will instruct all servers to add a ban (K-line) for\n"
"the mask which the user matched.\n"
" \n"
"AKILL ADD adds the given user@host/ip mask to the AKILL\n"
"AKILL ADD adds the given nick or user@host/ip mask to the AKILL\n"
"list for the given reason (which must be given).\n"
"expiry is specified as an integer followed by one of d \n"
"(days), h (hours), or m (minutes). Combinations (such as \n"
@@ -4623,7 +4623,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
"prevent the use of matching channels (on IRCds that \n"
"support it).\n"
" \n"
"SQLINE ADD adds the given mask to the SQLINE\n"
"SQLINE ADD adds the given (nick's) mask to the SQLINE\n"
"list for the given reason (which must be given).\n"
"expiry is specified as an integer followed by one of d \n"
"(days), h (hours), or m (minutes). Combinations (such as \n"
@@ -4665,7 +4665,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
"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"
"SZLINE ADD adds the given IP mask to the SZLINE\n"
"SZLINE ADD adds the given (nick's) IP mask to the SZLINE\n"
"list for the given reason (which must be given).\n"
"expiry is specified as an integer followed by one of d \n"
"(days), h (hours), or m (minutes). Combinations (such as \n"