1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 07:26:37 +02:00

Add a stats category for password encryption algorithms.

This commit is contained in:
Sadie Powell
2024-03-09 21:01:41 +00:00
parent 2f52fa723c
commit 1b86665d81
2 changed files with 75 additions and 4 deletions
+20 -2
View File
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Anope\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-07 23:06+0000\n"
"PO-Revision-Date: 2024-03-07 23:06+0000\n"
"POT-Creation-Date: 2024-03-09 21:00+0000\n"
"PO-Revision-Date: 2024-03-09 21:00+0000\n"
"Last-Translator: Sadie Powell <sadie@witchery.services>\n"
"Language-Team: English\n"
"Language: en_US\n"
@@ -4860,6 +4860,10 @@ msgstr "Method"
msgid "Missing parameter for mode %c."
msgstr "Missing parameter for mode %c."
#, c-format
msgid "Missing passwords: %zu"
msgstr "Missing passwords: %zu"
msgid "Mode"
msgstr "Mode"
@@ -5288,6 +5292,10 @@ msgstr "Password incorrect."
msgid "Password reset email for %s has been sent."
msgstr "Password reset email for %s has been sent."
#, c-format
msgid "Passwords encrypted with %s: %zu"
msgstr "Passwords encrypted with %s: %zu"
msgid "Peace"
msgstr "Peace"
@@ -7943,6 +7951,10 @@ msgstr "Unknown mode character %c ignored."
msgid "Unknown parameter: %s"
msgstr "Unknown parameter: %s"
#, c-format
msgid "Unknown passwords: %zu"
msgstr "Unknown passwords: %zu"
msgid "Unpooled"
msgstr "Unpooled"
@@ -8152,6 +8164,9 @@ msgid ""
"The RESET option currently resets the maximum user count\n"
"to the number of users currently present on the network.\n"
" \n"
"The PASSWORD option displays the encryption algorithms used\n"
"for user passwords.\n"
" \n"
"The UPLINK option displays information about the current\n"
"server Anope uses as an uplink to the network.\n"
" \n"
@@ -8169,6 +8184,9 @@ msgstr ""
"The RESET option currently resets the maximum user count\n"
"to the number of users currently present on the network.\n"
" \n"
"The PASSWORD option displays the encryption algorithms used\n"
"for user passwords.\n"
" \n"
"The UPLINK option displays information about the current\n"
"server Anope uses as an uplink to the network.\n"
" \n"
+55 -2
View File
@@ -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"