summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h6
-rw-r--r--src/cmd_quit.cpp4
-rw-r--r--src/helperfuncs.cpp25
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/users.cpp12
5 files changed, 27 insertions, 22 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 006e8092e..47ce9d971 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -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;
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index db71bbdb1..32bfff0fa 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -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;
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index ff6d6035a..5662c6914 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -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;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 497da8ff2..4b86d3816 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -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();
diff --git a/src/users.cpp b/src/users.cpp
index 44947fa6c..e4f63e3ba 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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'.