]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add unregistered user counter, this may also fix the (minor) m_conn_lusers shows...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 30 Dec 2006 14:34:49 +0000 (14:34 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 30 Dec 2006 14:34:49 +0000 (14:34 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6170 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd.h
src/cmd_quit.cpp
src/helperfuncs.cpp
src/inspircd.cpp
src/users.cpp

index 006e8092ed29021dd0199338b58120dfbe8d69ed..47ce9d971542c59884859effe829ba9d0b9caaec 100644 (file)
@@ -385,6 +385,12 @@ class InspIRCd : public classbase
        int time_delta;
 
  public:
+
+       /** Number of unregistered users online right now.
+        * (Unregistered means before USER/NICK/dns)
+        */
+       int unregistered_count;
+
         /** List of server names we've seen.
         */
        servernamelist servernames;
index db71bbdb19f52d53b4673d22125bc031a0b0e382..32bfff0faf9c10ef96884d720f894fd9045a3fd3 100644 (file)
@@ -106,6 +106,10 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                FOREACH_MOD(I_OnPostCommand,OnPostCommand("QUIT", parameters, pcnt, user, CMD_SUCCESS, original_command));
        }
 
+       if (user->registered != REG_ALL)
+               if (ServerInstance->unregistered_count)
+                       ServerInstance->unregistered_count--;
+
        DELETE(user);
        return CMD_USER_DELETED;
 }
index ff6d6035abea55e1dacf6bf6d78a20479421b81d..5662c691419980b10801fbd0c966b8d1c56c203f 100644 (file)
@@ -330,16 +330,7 @@ int InspIRCd::OperCount()
 
 int InspIRCd::UnregisteredUserCount()
 {
-       int c = 0;
-
-       for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
-       {
-               userrec* t = (userrec*)(*i);
-               if (t->registered != REG_ALL)
-                       c++;
-       }
-
-       return c;
+       return this->unregistered_count;
 }
 
 long InspIRCd::ChannelCount()
@@ -349,18 +340,10 @@ long InspIRCd::ChannelCount()
 
 long InspIRCd::LocalUserCount()
 {
-       int c = 0;
-
-       for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
-       {
-               userrec* t = (userrec*)(*i);
-               if (t->registered == REG_ALL)
-                       c++;
-       }
-
-       return c;
+       /* Doesnt count unregistered clients */
+       return (local_users.size() - this->UnregisteredUserCount());
 }
-
+       
 bool InspIRCd::IsChannel(const char *chname)
 {
        char *c;
index 497da8ff2f8fd93c5ea90a1e0d2398585f88f7ad..4b86d3816b5204c0df0e60c09878d3c4f10e1f69 100644 (file)
@@ -267,6 +267,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
        modules.resize(255);
        factory.resize(255);
 
+       this->unregistered_count = 0;
+
        this->clientlist = new user_hash();
        this->chanlist = new chan_hash();
 
index 44947fa6cd4372cbd3de535d6f9797cd190ee101..e4f63e3bae16ba075e00fc37c1060c94da86d7d3 100644 (file)
@@ -766,7 +766,11 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user, const std::string &qui
 
        if (reason.length() > MAXQUIT - 1)
                reason.resize(MAXQUIT - 1);
-       
+
+       if (user->registered != REG_ALL)
+               if (Instance->unregistered_count)
+                       Instance->unregistered_count--;
+
        if (IS_LOCAL(user))
        {
                user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str());
@@ -983,6 +987,8 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
        userrec* New;
        int j = 0;
 
+       Instance->unregistered_count++;
+
        /*
         * fix by brain.
         * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
@@ -1177,6 +1183,10 @@ void userrec::FullConnect(CullList* Goners)
 
        this->ShowMOTD();
 
+       /* Now registered */
+       if (ServerInstance->unregistered_count)
+               ServerInstance->unregistered_count--;
+
        /*
         * fix 3 by brain, move registered = 7 below these so that spurious modes and host
         * changes dont go out onto the network and produce 'fake direction'.