summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/bs_botlist.cpp2
-rw-r--r--modules/commands/cs_akick.cpp2
-rw-r--r--modules/commands/cs_seen.cpp2
-rw-r--r--modules/commands/ns_ghost.cpp2
-rw-r--r--modules/commands/os_akill.cpp2
-rw-r--r--modules/commands/os_list.cpp7
-rw-r--r--modules/commands/os_login.cpp2
-rw-r--r--modules/commands/os_noop.cpp2
-rw-r--r--modules/commands/os_session.h2
-rw-r--r--modules/commands/os_stats.cpp50
-rw-r--r--modules/commands/os_sxline.cpp8
-rw-r--r--modules/database/db_plain.cpp2
-rw-r--r--modules/protocol/bahamut.cpp2
-rw-r--r--modules/protocol/hybrid.cpp2
-rw-r--r--modules/protocol/inspircd-ts6.h2
-rw-r--r--modules/protocol/inspircd11.cpp2
-rw-r--r--modules/protocol/inspircd12.cpp2
-rw-r--r--modules/protocol/inspircd20.cpp2
-rw-r--r--modules/protocol/plexus.cpp4
-rw-r--r--modules/protocol/ratbox.cpp4
-rw-r--r--modules/protocol/unreal.cpp2
21 files changed, 78 insertions, 27 deletions
diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp
index 176040b10..a4a7c2586 100644
--- a/modules/commands/bs_botlist.cpp
+++ b/modules/commands/bs_botlist.cpp
@@ -29,7 +29,7 @@ class CommandBSBotList : public Command
list.addColumn("Nick").addColumn("Mask");
- for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
{
BotInfo *bi = it->second;
diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp
index 6c0dfa386..1425d1636 100644
--- a/modules/commands/cs_akick.cpp
+++ b/modules/commands/cs_akick.cpp
@@ -95,7 +95,7 @@ class CommandCSAKick : public Command
{
/* Match against all currently online users with equal or
* higher access. - Viper */
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u2 = it->second;
diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp
index cbbd1c35c..d2686e013 100644
--- a/modules/commands/cs_seen.cpp
+++ b/modules/commands/cs_seen.cpp
@@ -21,7 +21,7 @@ enum TypeInfo
struct SeenInfo;
static SeenInfo *FindInfo(const Anope::string &nick);
-typedef Anope::insensitive_map<SeenInfo *> database_map;
+typedef Anope::hash_map<SeenInfo *> database_map;
database_map database;
struct SeenInfo : Serializable
diff --git a/modules/commands/ns_ghost.cpp b/modules/commands/ns_ghost.cpp
index 92d1840af..e7289f728 100644
--- a/modules/commands/ns_ghost.cpp
+++ b/modules/commands/ns_ghost.cpp
@@ -171,7 +171,7 @@ class NSGhost : public Module
~NSGhost()
{
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
it->second->Shrink("ns_ghost_info");
}
diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp
index ff840d353..f09d1f87a 100644
--- a/modules/commands/os_akill.cpp
+++ b/modules/commands/os_akill.cpp
@@ -163,7 +163,7 @@ class CommandOSAKill : public Command
x->UID = XLineManager::GenerateUID();
unsigned int affected = 0;
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (akills->Check(it->second, x))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp
index 2850e0203..0272742c1 100644
--- a/modules/commands/os_list.cpp
+++ b/modules/commands/os_list.cpp
@@ -153,9 +153,14 @@ class CommandOSUserList : public Command
}
else
{
+ /* Historically this has been ordered, so... */
+ Anope::map<User *> ordered_map;
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ ordered_map[it->first] = it->second;
+
source.Reply(_("Users list:"));
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (Anope::map<User *>::const_iterator it = ordered_map.begin(); it != ordered_map.end(); ++it)
{
User *u2 = it->second;
diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp
index c282b9662..7b223eb1f 100644
--- a/modules/commands/os_login.cpp
+++ b/modules/commands/os_login.cpp
@@ -121,7 +121,7 @@ class OSLogin : public Module
~OSLogin()
{
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
it->second->Shrink("os_login_password_correct");
}
diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp
index 21ec0dd91..edb5b2eca 100644
--- a/modules/commands/os_noop.cpp
+++ b/modules/commands/os_noop.cpp
@@ -41,7 +41,7 @@ class CommandOSNOOP : public Command
Anope::string reason = "NOOP command used by " + source.GetNick();
/* Kill all the IRCops of the server */
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
{
User *u2 = it->second;
++it;
diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h
index ee37a7594..070975fd2 100644
--- a/modules/commands/os_session.h
+++ b/modules/commands/os_session.h
@@ -27,7 +27,7 @@ struct Exception : Serializable
class SessionService : public Service
{
public:
- typedef std::map<cidr, Session *> SessionMap;
+ typedef std::tr1::unordered_map<cidr, Session *, cidr::hash> SessionMap;
typedef std::vector<Exception *> ExceptionVector;
SessionService(Module *m) : Service(m, "SessionService", "session") { }
diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp
index a418396bd..83f13a90a 100644
--- a/modules/commands/os_stats.cpp
+++ b/modules/commands/os_stats.cpp
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
+#include "os_session.h"
struct Stats : Serializable
{
@@ -155,12 +156,52 @@ class CommandOSStats : public Command
return;
}
+ template<typename T> void GetHashStats(const T& map, size_t& entries, size_t& buckets, size_t& max_chain)
+ {
+ entries = map.size(), buckets = map.bucket_count(), max_chain = 0;
+ for (size_t i = 0; i < buckets; ++i)
+ if (map.bucket_size(i) > max_chain)
+ max_chain = map.bucket_size(i);
+ }
+
+ void DoStatsHash(CommandSource &source)
+ {
+ size_t entries, buckets, max_chain;
+
+ GetHashStats(UserListByNick, entries, buckets, max_chain);
+ source.Reply(_("Users (nick): %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+
+ if (!UserListByUID.empty())
+ {
+ GetHashStats(UserListByUID, entries, buckets, max_chain);
+ source.Reply(_("Users (uid): %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+ }
+
+ GetHashStats(ChannelList, entries, buckets, max_chain);
+ source.Reply(_("Channels: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+
+ GetHashStats(*RegisteredChannelList, entries, buckets, max_chain);
+ source.Reply(_("Registered channels: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+
+ GetHashStats(*NickAliasList, entries, buckets, max_chain);
+ source.Reply(_("Registered nicknames: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+
+ GetHashStats(*NickCoreList, entries, buckets, max_chain);
+ source.Reply(_("Registered nick groups: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+
+ if (session_service)
+ {
+ GetHashStats(session_service->GetSessions(), entries, buckets, max_chain);
+ source.Reply(_("Sessions: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
+ }
+ }
+
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 | ALL | RESET | UPLINK]"));
+ this->SetSyntax(_("[AKILL | ALL | HASH | RESET | UPLINK]"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
@@ -179,7 +220,10 @@ class CommandOSStats : public Command
if (extra.equals_ci("ALL") || extra.equals_ci("UPLINK"))
this->DoStatsUplink(source);
- if (!extra.empty() && !extra.equals_ci("ALL") && !extra.equals_ci("AKILL") && !extra.equals_ci("UPLINK"))
+ if (extra.equals_ci("ALL") || extra.equals_ci("HASH"))
+ this->DoStatsHash(source);
+
+ if (!extra.empty() && !extra.equals_ci("ALL") && !extra.equals_ci("AKILL") && !extra.equals_ci("UPLINK") && !extra.equals_ci("HASH"))
source.Reply(_("Unknown STATS option \002%s\002."), extra.c_str());
}
@@ -200,6 +244,8 @@ class CommandOSStats : public Command
"The \002UPLINK\002 option displays information about the current\n"
"server Anope uses as an uplink to the network.\n"
" \n"
+ "The \002HASH\002 option displays information about the hash maps.\n"
+ " \n"
"The \002ALL\002 displays the user and uptime statistics, and\n"
"everything you'd see with the \002UPLINK\002 option."));
return true;
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp
index 8cd3d9f7a..ea7f7840d 100644
--- a/modules/commands/os_sxline.cpp
+++ b/modules/commands/os_sxline.cpp
@@ -357,7 +357,7 @@ class CommandOSSNLine : public CommandOSSXLineBase
x->UID = XLineManager::GenerateUID();
unsigned int affected = 0;
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (this->xlm()->Check(it->second, x))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
@@ -386,7 +386,7 @@ class CommandOSSNLine : public CommandOSSXLineBase
Anope::string rreason = "G-Lined: " + reason;
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *user = it->second;
++it;
@@ -560,7 +560,7 @@ class CommandOSSQLine : public CommandOSSXLineBase
x->UID = XLineManager::GenerateUID();
unsigned int affected = 0;
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (this->xlm()->Check(it->second, x))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
@@ -607,7 +607,7 @@ class CommandOSSQLine : public CommandOSSXLineBase
}
else
{
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *user = it->second;
++it;
diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp
index 1017db8cc..e6d430556 100644
--- a/modules/database/db_plain.cpp
+++ b/modules/database/db_plain.cpp
@@ -731,7 +731,7 @@ class DBPlain : public Module
//FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na));
}
- for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
{
BotInfo *bi = it->second;
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index c5be3c3fa..4a5362bcc 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -198,7 +198,7 @@ class BahamutIRCdProto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
return;
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index 88d10a841..52f58f254 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -127,7 +127,7 @@ class HybridProto : public IRCDProto
* No user (this akill was just added), and contains nick and/or realname.
* Find users that match and ban them.
*/
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index a10deea4f..38ad32e26 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -151,7 +151,7 @@ class InspIRCdTS6Proto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
return;
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index d1ee82bbb..10a47ae3e 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -116,7 +116,7 @@ class InspIRCdProto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
return;
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 97d2b6259..3d925bd4a 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -534,7 +534,7 @@ class ProtoInspIRCd : public Module
void OnServerSync(Server *s) anope_override
{
if (nickserv)
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
if (u->server == s && !u->IsIdentified())
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 2d3a3c4f2..8dbdfb2ff 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -630,7 +630,7 @@ class ProtoInspIRCd : public Module
void OnServerSync(Server *s) anope_override
{
if (nickserv)
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
if (u->server == s && !u->IsIdentified())
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 5f1af0cec..948a715ac 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -107,7 +107,7 @@ class PlexusProto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
return;
@@ -757,7 +757,7 @@ class ProtoPlexus : public Module
void OnServerSync(Server *s) anope_override
{
if (nickserv)
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
if (u->server == s && !u->IsIdentified())
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 4acf5e79a..317ced1ff 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -97,7 +97,7 @@ class RatboxProto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
return;
@@ -631,7 +631,7 @@ class ProtoRatbox : public Module
void OnServerSync(Server *s) anope_override
{
if (nickserv)
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
if (u->server == s && !u->IsIdentified())
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 1e89f4795..03a63687f 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -88,7 +88,7 @@ class UnrealIRCdProto : public IRCDProto
if (!u)
{
/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
if (x->manager->Check(it->second, x))
this->SendAkill(it->second, x);
return;