]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Access local user list via new UserManager::GetLocalUsers() and make local_users...
authorAttila Molnar <attilamolnar@hush.com>
Sat, 19 Jul 2014 12:28:51 +0000 (14:28 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Sat, 19 Jul 2014 12:28:51 +0000 (14:28 +0200)
14 files changed:
include/usermanager.h
src/coremods/core_privmsg.cpp
src/coremods/core_stats.cpp
src/coremods/core_wallops.cpp
src/helperfuncs.cpp
src/inspircd.cpp
src/modules/extra/m_geoip.cpp
src/modules/m_close.cpp
src/modules/m_jumpserver.cpp
src/modules/m_modenotice.cpp
src/modules/m_nationalchars.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/treeserver.cpp
src/xline.cpp

index 2f77e8333239a7e0c4b2c390779be0d1df5d01db..361584cdaa184cd21cf30d8d218b5587d11748af 100644 (file)
@@ -52,6 +52,10 @@ class CoreExport UserManager : public fakederef<UserManager>
         */
        const CloneCounts zeroclonecounts;
 
+       /** Local client list, a list containing only local clients
+        */
+       LocalList local_users;
+
  public:
        /** Constructor, initializes variables
         */
@@ -70,10 +74,6 @@ class CoreExport UserManager : public fakederef<UserManager>
         */
        user_hash uuidlist;
 
-       /** Local client list, a list containing only local clients
-        */
-       LocalList local_users;
-
        /** Oper list, a vector containing all local and remote opered users
         */
        OperList all_opers;
@@ -173,6 +173,11 @@ class CoreExport UserManager : public fakederef<UserManager>
         */
        user_hash& GetUsers() { return clientlist; }
 
+       /** Get a list containing all local users
+        * @return A const list of local users
+        */
+       const LocalList& GetLocalUsers() const { return local_users; }
+
        /** Send a server notice to all local users
         * @param text The text format string to send
         * @param ... The format arguments
index 5ec3097a5c4329f7e81c94d712c8508d9487b4cd..34527027c89e28358be1a4d6d06c9608b7b46b3e 100644 (file)
@@ -67,7 +67,7 @@ class MessageCommandBase : public Command
 void MessageCommandBase::SendAll(User* user, const std::string& msg, MessageType mt)
 {
        const std::string message = ":" + user->GetFullHost() + " " + MessageTypeString[mt] + " $* :" + msg;
-       const UserManager::LocalList& list = ServerInstance->Users->local_users;
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
        for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
        {
                if ((*i)->registered == REG_ALL)
index 0034889ab631bfd645d3da4c0b988e37cffe52e8..1192b1be929299502db9811ef2bb125a1aadaefd 100644 (file)
@@ -54,7 +54,7 @@ static void GenerateStatsLl(User* user, string_list& results, char c)
 {
        results.push_back(InspIRCd::Format("211 %s nick[ident@%s] sendq cmds_out bytes_out cmds_in bytes_in time_open", user->nick.c_str(), (c == 'l' ? "host" : "ip")));
 
-       const UserManager::LocalList& list = ServerInstance->Users->local_users;
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
        for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
        {
                LocalUser* u = *i;
index 871a6e60ef541522e7bae8cdf20c1a4751f6c3b4..0210df8ee869d185be7f52e79a38a893d697f2f4 100644 (file)
@@ -55,7 +55,8 @@ CmdResult CommandWallops::Handle (const std::vector<std::string>& parameters, Us
        std::string wallop("WALLOPS :");
        wallop.append(parameters[0]);
 
-       for (UserManager::LocalList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
        {
                User* t = *i;
                if (t->IsModeSet(wallopsmode))
index 55a1b9f8341306903b2d17fc067874b874062a6f..7b2a29f7711ecfbb97cba3d3596464c99155a33b 100644 (file)
@@ -82,7 +82,8 @@ Channel* InspIRCd::FindChan(const std::string &chan)
 /* Send an error notice to all users, registered or not */
 void InspIRCd::SendError(const std::string &s)
 {
-       for (UserManager::LocalList::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); ++i)
+       const UserManager::LocalList& list = Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
        {
                User* u = *i;
                if (u->registered == REG_ALL)
index fec4aedeafb4110ad7ea5b3d27964ac3259be64e..403ba535502281b6672ec5c21d624a908cf13b36 100644 (file)
@@ -109,8 +109,8 @@ void InspIRCd::Cleanup()
        ports.clear();
 
        /* Close all client sockets, or the new process inherits them */
-       UserManager::LocalList& list = Users->local_users;
-       for (UserManager::LocalList::iterator i = list.begin(); i != list.end(); ++i)
+       const UserManager::LocalList& list = Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
                Users->QuitUser(*i, "Server shutdown");
 
        GlobalCulls.Apply();
index f8e358bf733603703cc61550f4afc6fc564c4a4d..3561d1a5da2f21d18bbb61c4acf072b88f4145dc 100644 (file)
@@ -56,7 +56,8 @@ class ModuleGeoIP : public Module
                if (gi == NULL)
                                throw ModuleException("Unable to initialize geoip, are you missing GeoIP.dat?");
 
-               for (UserManager::LocalList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+               for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
                {
                        LocalUser* user = *i;
                        if ((user->registered == REG_ALL) && (!ext.get(user)))
@@ -101,7 +102,9 @@ class ModuleGeoIP : public Module
 
                unsigned int unknown = 0;
                std::map<std::string, unsigned int> results;
-               for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+               for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
                {
                        std::string* cc = ext.get(*i);
                        if (cc)
index f8bac669dff50b21305bec99b8cb5716470390eb..f3c751f177558f9df8af90a690657206c7745629 100644 (file)
@@ -35,7 +35,8 @@ class CommandClose : public Command
        {
                std::map<std::string,int> closed;
 
-               for (UserManager::LocalList::const_iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); ++u)
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+               for (UserManager::LocalList::const_iterator u = list.begin(); u != list.end(); ++u)
                {
                        LocalUser* user = *u;
                        if (user->registered != REG_ALL)
index 9ee224704ce46925b409f58601636b2af410ac1a..599144448833c1aea22837fbfd4543b915151672 100644 (file)
@@ -108,7 +108,8 @@ class CommandJumpserver : public Command
                        if (redirect_all_immediately)
                        {
                                /* Redirect everyone but the oper sending the command */
-                               for (UserManager::LocalList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+                               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+                               for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
                                {
                                        LocalUser* t = *i;
                                        if (!t->IsOper())
index 0078c6325d516e951a34981312ff9fd1ae96a12d..056eb4a626a5f63c29f1fbd9ca66edd3a9248dcc 100644 (file)
@@ -32,7 +32,8 @@ class CommandModeNotice : public Command
        {
                std::string msg = "*** From " + src->nick + ": " + parameters[1];
                int mlen = parameters[0].length();
-               for (UserManager::LocalList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+               for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
                {
                        User* user = *i;
                        for (int n = 0; n < mlen; n++)
index 3efd97a24aad493375b60f72b2b068ad42edbcad..0650cb3d000b004d704f15325f61b912cea5290a 100644 (file)
@@ -261,7 +261,8 @@ class ModuleNationalChars : public Module
                if (!forcequit)
                        return;
 
-               for (UserManager::LocalList::const_iterator iter = ServerInstance->Users->local_users.begin(); iter != ServerInstance->Users->local_users.end(); ++iter)
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+               for (UserManager::LocalList::const_iterator iter = list.begin(); iter != list.end(); ++iter)
                {
                        /* Fix by Brain: Dont quit UID users */
                        User* n = *iter;
index b24d8c6eef28d9b63de9ecbd20c515b098750115..8a1aed08fbc73c7f3f05567e1b554acefb4d1619 100644 (file)
@@ -62,7 +62,7 @@ namespace
                // Does not change the server of quitting users because those are not in the list
 
                ServerInstance->FakeClient->server = newserver;
-               const UserManager::LocalList& list = ServerInstance->Users->local_users;
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
                for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
                        (*i)->server = newserver;
        }
@@ -70,7 +70,7 @@ namespace
        void ResetMembershipIds()
        {
                // Set all membership ids to 0
-               const UserManager::LocalList& list = ServerInstance->Users->local_users;
+               const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
                for (UserManager::LocalList::iterator i = list.begin(); i != list.end(); ++i)
                {
                        LocalUser* user = *i;
index 589e9b8892cf97a9f4a4b386cbed672fe2c63135..74854acc9c441427f24c3cc1a3358fedd3611b72 100644 (file)
@@ -38,7 +38,7 @@ TreeServer::TreeServer()
        , VersionString(ServerInstance->GetVersionString())
        , fullversion(ServerInstance->GetVersionString(true))
        , Socket(NULL), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient)
-       , age(ServerInstance->Time()), Warned(false), bursting(false), UserCount(ServerInstance->Users->local_users.size())
+       , age(ServerInstance->Time()), Warned(false), bursting(false), UserCount(ServerInstance->Users.GetLocalUsers().size())
        , OperCount(0), rtt(0), StartBurst(0), Hidden(false)
 {
        AddHashEntry();
index 62afcc28512fcc867343f83421c62bd486150d98..3eb556234d3a12a16bb9cb851725cdc5c4cd65c3 100644 (file)
@@ -155,7 +155,8 @@ void XLineManager::CheckELines()
        if (ELines.empty())
                return;
 
-       for (UserManager::LocalList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
                LocalUser* u = *u2;
 
@@ -325,7 +326,8 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User*
 void ELine::Unset()
 {
        /* remove exempt from everyone and force recheck after deleting eline */
-       for (UserManager::LocalList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
                LocalUser* u = *u2;
                u->exempt = false;
@@ -429,8 +431,8 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
 // applies lines, removing clients and changing nicks etc as applicable
 void XLineManager::ApplyLines()
 {
-       UserManager::LocalList& list = ServerInstance->Users->local_users;
-       for (UserManager::LocalList::iterator j = list.begin(); j != list.end(); ++j)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator j = list.begin(); j != list.end(); ++j)
        {
                LocalUser* u = *j;
 
@@ -679,7 +681,8 @@ bool GLine::Matches(const std::string &str)
 void ELine::OnAdd()
 {
        /* When adding one eline, only check the one eline */
-       for (UserManager::LocalList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
                LocalUser* u = *u2;
                if (this->Matches(u))