diff options
author | Adam <Adam@anope.org> | 2010-11-14 17:05:35 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:33:58 -0500 |
commit | 2e9a632e1410fbeadc1b7a0418cf66247e0e458c (patch) | |
tree | 027177fef4b96c545a7a0c06a399cc8238554807 | |
parent | 3c9d4e9dafdd0918a3539e545cc99646e604757d (diff) |
Allow akill/szline/sqline to accept user names as a mask argument
-rw-r--r-- | modules/core/os_akill.cpp | 18 | ||||
-rw-r--r-- | modules/core/os_snline.cpp | 14 | ||||
-rw-r--r-- | modules/core/os_sqline.cpp | 17 | ||||
-rw-r--r-- | modules/core/os_szline.cpp | 18 | ||||
-rw-r--r-- | src/language.cpp | 12 |
5 files changed, 69 insertions, 10 deletions
diff --git a/modules/core/os_akill.cpp b/modules/core/os_akill.cpp index 973aaecda..fab4a7fee 100644 --- a/modules/core/os_akill.cpp +++ b/modules/core/os_akill.cpp @@ -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) diff --git a/modules/core/os_snline.cpp b/modules/core/os_snline.cpp index fb83f5e52..fb4e84dce 100644 --- a/modules/core/os_snline.cpp +++ b/modules/core/os_snline.cpp @@ -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) diff --git a/modules/core/os_sqline.cpp b/modules/core/os_sqline.cpp index e409c1bd7..72969aa54 100644 --- a/modules/core/os_sqline.cpp +++ b/modules/core/os_sqline.cpp @@ -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) diff --git a/modules/core/os_szline.cpp b/modules/core/os_szline.cpp index 2421cbdf6..459dd0f1d 100644 --- a/modules/core/os_szline.cpp +++ b/modules/core/os_szline.cpp @@ -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) diff --git a/src/language.cpp b/src/language.cpp index 7cae1e4bb..a49508d0c 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -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" |