summaryrefslogtreecommitdiff
path: root/modules/operserv
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-09 21:01:41 +0000
committerSadie Powell <sadie@witchery.services>2024-03-09 22:22:56 +0000
commit1b86665d81c0beefb140dcd2eaac8274e88617da (patch)
tree5187b730bb1a521e9f86c142b1bf176ba514911f /modules/operserv
parent2f52fa723c47dcc398a4b7ffd62b6f181565589a (diff)
Add a stats category for password encryption algorithms.
Diffstat (limited to 'modules/operserv')
-rw-r--r--modules/operserv/os_stats.cpp57
1 files changed, 55 insertions, 2 deletions
diff --git a/modules/operserv/os_stats.cpp b/modules/operserv/os_stats.cpp
index 52c7cb7dc..780151916 100644
--- a/modules/operserv/os_stats.cpp
+++ b/modules/operserv/os_stats.cpp
@@ -200,12 +200,43 @@ private:
}
}
+ void DoStatsPassword(CommandSource &source)
+ {
+ Anope::map<size_t> counts;
+ size_t missing = 0;
+ size_t unknown = 0;
+ for (const auto &[_, nc] : *NickCoreList)
+ {
+ if (nc->pass.empty())
+ {
+ missing++;
+ continue;
+ }
+
+ auto sep = nc->pass.find(':');
+ if (sep == Anope::string::npos)
+ {
+ unknown++;
+ continue;
+ }
+
+ counts[nc->pass.substr(0, sep)]++;
+ }
+
+ for (const auto &[algo, count] : counts)
+ source.Reply(_("Passwords encrypted with %s: %zu"), algo.c_str(), count);
+ if (missing)
+ source.Reply(_("Missing passwords: %zu"), missing);
+ if (unknown)
+ source.Reply(_("Unknown passwords: %zu"), unknown);
+ }
+
public:
CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1),
akills("XLineManager", "xlinemanager/sgline"), snlines("XLineManager", "xlinemanager/snline"), sqlines("XLineManager", "xlinemanager/sqline")
{
this->SetDesc(_("Show status of services and network"));
- this->SetSyntax("[AKILL | HASH | UPLINK | UPTIME | ALL | RESET]");
+ this->SetSyntax("[AKILL | HASH | PASSWORD | UPLINK | UPTIME | ALL | RESET]");
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -217,19 +248,38 @@ public:
if (extra.equals_ci("RESET"))
return this->DoStatsReset(source);
+ bool handled = false;
if (extra.equals_ci("ALL") || extra.equals_ci("AKILL"))
+ {
this->DoStatsAkill(source);
+ handled = true;
+ }
if (extra.equals_ci("ALL") || extra.equals_ci("HASH"))
+ {
this->DoStatsHash(source);
+ handled = true;
+ }
+
+ if (extra.equals_ci("ALL") || extra.equals_ci("PASSWORD"))
+ {
+ this->DoStatsPassword(source);
+ handled = true;
+ }
if (extra.equals_ci("ALL") || extra.equals_ci("UPLINK"))
+ {
this->DoStatsUplink(source);
+ handled = true;
+ }
if (extra.empty() || extra.equals_ci("ALL") || extra.equals_ci("UPTIME"))
+ {
this->DoStatsUptime(source);
+ handled = true;
+ }
- if (!extra.empty() && !extra.equals_ci("ALL") && !extra.equals_ci("AKILL") && !extra.equals_ci("HASH") && !extra.equals_ci("UPLINK") && !extra.equals_ci("UPTIME"))
+ if (!handled)
source.Reply(_("Unknown STATS option: \002%s\002"), extra.c_str());
}
@@ -247,6 +297,9 @@ public:
"The \002RESET\002 option currently resets the maximum user count\n"
"to the number of users currently present on the network.\n"
" \n"
+ "The \002PASSWORD\002 option displays the encryption algorithms used\n"
+ "for user passwords.\n"
+ " \n"
"The \002UPLINK\002 option displays information about the current\n"
"server Anope uses as an uplink to the network.\n"
" \n"