]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/usermanager.cpp
Update m_filter* to 1.2 API (it was still using Implements()), also implement <exempt...
[user/henk/code/inspircd.git] / src / usermanager.cpp
index d518b790efa1c06046ea0f2765426523a2996d78..1917c780e3c73d11f2d25d00dcc771e63919d983 100644 (file)
@@ -31,7 +31,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
        catch (...)
        {
                Instance->Log(DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkies have been unleashed.");
-               Instance->WriteOpers("*** WARNING *** Duplicate UUID allocated!");
+               Instance->SNO->WriteToSnoMask('A', "WARNING *** Duplicate UUID allocated!");
                return;
        }
 
@@ -49,6 +49,19 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
 #endif
        inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
 
+       (*(Instance->clientlist))[New->uuid] = New;
+
+       /* The users default nick is their UUID */
+       strlcpy(New->nick, New->uuid, NICKMAX - 1);
+
+       New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);
+       /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
+       strcpy(New->ident, "unknown");
+
+       New->registered = REG_NONE;
+       New->signon = Instance->Time() + Instance->Config->dns_timeout;
+       New->lastping = 1;
+
        New->SetSockAddr(socketfamily, ipaddr, port);
 
        New->SetFd(socket);
@@ -83,7 +96,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
 
        if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
        {
-               Instance->WriteOpers("*** Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
+               Instance->SNO->WriteToSnoMask('A', "Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
                User::QuitUser(Instance, New,"No more connections allowed");
                return;
        }
@@ -142,14 +155,11 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
                }
        }
 
-        if (socket > -1)
-        {
-                if (!Instance->SE->AddFd(New))
-                {
-                       Instance->Log(DEBUG,"Internal error on new connection");
-                       User::QuitUser(Instance, New, "Internal error handling connection");
-                }
-        }
+       if (!Instance->SE->AddFd(New))
+       {
+               Instance->Log(DEBUG,"Internal error on new connection");
+               User::QuitUser(Instance, New, "Internal error handling connection");
+       }
 
        /* NOTE: even if dns lookups are *off*, we still need to display this.
         * BOPM and other stuff requires it.
@@ -224,3 +234,41 @@ unsigned long UserManager::LocalCloneCount(User *user)
        else
                return 0;
 }
+
+/* this function counts all users connected, wether they are registered or NOT. */
+unsigned int UserManager::UserCount()
+{
+       /*
+        * XXX: Todo:
+        *  As part of this restructuring, move clientlist/etc fields into usermanager.
+        *      -- w00t
+        */
+       return ServerInstance->clientlist->size();
+}
+
+/* this counts only registered users, so that the percentages in /MAP don't mess up */
+unsigned int UserManager::RegisteredUserCount()
+{
+       return ServerInstance->clientlist->size() - this->UnregisteredUserCount();
+}
+
+/* return how many users are opered */
+unsigned int UserManager::OperCount()
+{
+       return ServerInstance->all_opers.size();
+}
+
+/* return how many users are unregistered */
+unsigned int UserManager::UnregisteredUserCount()
+{
+       return ServerInstance->unregistered_count;
+}
+
+/* return how many local registered users there are */
+unsigned int UserManager::LocalUserCount()
+{
+       /* Doesnt count unregistered clients */
+       return (ServerInstance->local_users.size() - this->UnregisteredUserCount());
+}
+
+