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 /modules | |
parent | 3c9d4e9dafdd0918a3539e545cc99646e604757d (diff) |
Allow akill/szline/sqline to accept user names as a mask argument
Diffstat (limited to 'modules')
-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 |
4 files changed, 63 insertions, 4 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) |