]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Was checking 'channel', not 'dest'.
[user/henk/code/inspircd.git] / src / users.cpp
index bb6b71782cdf454f6955ccfbca34db0ef05b7265..02f6a28ee60b26478b831314f5019a92e7d868b4 100644 (file)
 #include "xline.h"
 #include "cull_list.h"
 
-irc::whowas::whowas_users whowas;
 static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
 
-typedef std::map<irc::string,char*> opertype_t;
-typedef opertype_t operclass_t;
-
-opertype_t opertypes;
-operclass_t operclass;
-
 /* XXX: Used for speeding up WriteCommon operations */
 unsigned long uniq_id = 0;
 
 bool InitTypes(ServerConfig* conf, const char* tag)
 {
-       for (opertype_t::iterator n = opertypes.begin(); n != opertypes.end(); n++)
+       for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++)
        {
                if (n->second)
                        delete[] n->second;
        }
        
-       opertypes.clear();
+       conf->opertypes.clear();
        return true;
 }
 
 bool InitClasses(ServerConfig* conf, const char* tag)
 {
-       for (operclass_t::iterator n = operclass.begin(); n != operclass.end(); n++)
+       for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++)
        {
                if (n->second)
                        delete[] n->second;
        }
        
-       operclass.clear();
+       conf->operclass.clear();
        return true;
 }
 
@@ -65,7 +58,7 @@ bool DoType(ServerConfig* conf, const char* tag, char** entries, void** values,
        char* TypeName = (char*)values[0];
        char* Classes = (char*)values[1];
        
-       opertypes[TypeName] = strdup(Classes);
+       conf->opertypes[TypeName] = strdup(Classes);
        conf->GetInstance()->Log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes);
        return true;
 }
@@ -75,7 +68,7 @@ bool DoClass(ServerConfig* conf, const char* tag, char** entries, void** values,
        char* ClassName = (char*)values[0];
        char* CommandList = (char*)values[1];
        
-       operclass[ClassName] = strdup(CommandList);
+       conf->operclass[ClassName] = strdup(CommandList);
        conf->GetInstance()->Log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList);
        return true;
 }
@@ -456,15 +449,15 @@ bool userrec::HasPermission(const std::string &command)
        // are they even an oper at all?
        if (*this->oper)
        {
-               opertype_t::iterator iter_opertype = opertypes.find(this->oper);
-               if (iter_opertype != opertypes.end())
+               opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
+               if (iter_opertype != ServerInstance->Config->opertypes.end())
                {
                        char* Classes = strdup(iter_opertype->second);
                        char* myclass = strtok_r(Classes," ",&savept);
                        while (myclass)
                        {
-                               operclass_t::iterator iter_operclass = operclass.find(myclass);
-                               if (iter_operclass != operclass.end())
+                               operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
+                               if (iter_operclass != ServerInstance->Config->operclass.end())
                                {
                                        char* CommandList = strdup(iter_operclass->second);
                                        mycmd = strtok_r(CommandList," ",&savept2);
@@ -809,9 +802,9 @@ namespace irc
                }
 
                /* every hour, run this function which removes all entries over 3 days */
-               void MaintainWhoWas(time_t t)
+               void MaintainWhoWas(InspIRCd* ServerInstance, time_t t)
                {
-                       for (whowas_users::iterator iter = ::whowas.begin(); iter != ::whowas.end(); iter++)
+                       for (whowas_users::iterator iter = ServerInstance->whowas.begin(); iter != ServerInstance->whowas.end(); iter++)
                        {
                                whowas_set* n = (whowas_set*)iter->second;
                                if (n->size())
@@ -831,21 +824,27 @@ namespace irc
 /* adds or updates an entry in the whowas list */
 void userrec::AddToWhoWas()
 {
-       irc::whowas::whowas_users::iterator iter = whowas.find(this->nick);
+       irc::whowas::whowas_users::iterator iter = ServerInstance->whowas.find(this->nick);
 
-       if (iter == whowas.end())
+       ServerInstance->Log(DEBUG,"Add to whowas lists");
+
+       if (iter == ServerInstance->whowas.end())
        {
+               ServerInstance->Log(DEBUG,"Adding new whowas set for %s",this->nick);
                irc::whowas::whowas_set* n = new irc::whowas::whowas_set;
                irc::whowas::WhoWasGroup *a = new irc::whowas::WhoWasGroup(this);
                n->push_back(a);
-               whowas[this->nick] = n;
+               ServerInstance->whowas[this->nick] = n;
        }
        else
        {
                irc::whowas::whowas_set* group = (irc::whowas::whowas_set*)iter->second;
 
+               ServerInstance->Log(DEBUG,"Using existing whowas group for %s",this->nick);
+
                if (group->size() > 10)
                {
+                       ServerInstance->Log(DEBUG,"Trimming existing group to ten entries for %s",this->nick);
                        irc::whowas::WhoWasGroup *a = (irc::whowas::WhoWasGroup*)*(group->begin());
                        DELETE(a);
                        group->pop_front();
@@ -956,6 +955,7 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
                userrec::QuitUser(Instance, New, "Server is full");
                return;
        }
+
        ELine* e = Instance->XLines->matches_exception(New);
        if (!e)
        {
@@ -983,18 +983,16 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
 
 long userrec::GlobalCloneCount()
 {
-       char u1[128] = {0};
-       char u2[128] = {0};
+       char u1[128];
+       char u2[128];
        long x = 0;
-       
-       this->GetIPString(u2);
-       
+
        for (user_hash::const_iterator a = ServerInstance->clientlist.begin(); a != ServerInstance->clientlist.end(); a++)
        {
                /* We have to match ip's as strings - we don't know what protocol
                 * a remote user may be using
                 */
-               if (strcmp(a->second->GetIPString(u1), u2) == 0)
+               if (strcmp(a->second->GetIPString(u1), this->GetIPString(u2)) == 0)
                        x++;
        }