]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix sillies
[user/henk/code/inspircd.git] / src / users.cpp
index 0ece0aaddd7163ef6313ad79eb7a2fe5c61bc673..cdacdc5c2ab52f126e59a093306e7f3bf8071310 100644 (file)
@@ -98,7 +98,7 @@ void User::StartDNSLookup()
        try
        {
                bool cached;
-               const char* sip = this->GetIPString();
+               const char* sip = this->GetIPString(false);
 
                /* Special case for 4in6 (Have i mentioned i HATE 4in6?) */
                if (!strncmp(sip, "0::ffff:", 8))
@@ -817,21 +817,6 @@ void User::UnOper()
        }
 }
 
-void User::QuitUser(InspIRCd* Instance, User *user, const std::string &quitreason, const char* operreason)
-{
-       Instance->Logs->Log("USERS", DEBUG,"QuitUser: %s '%s'", user->nick, quitreason.c_str());
-       user->Write("ERROR :Closing link (%s@%s) [%s]", user->ident, user->host, *operreason ? operreason : quitreason.c_str());
-       user->quietquit = false;
-       user->quitmsg = quitreason;
-
-       if (!*operreason)
-               user->operquitmsg = quitreason;
-       else
-               user->operquitmsg = operreason;
-
-       Instance->GlobalCulls.AddItem(user);
-}
-
 /* adds or updates an entry in the whowas list */
 void User::AddToWhoWas()
 {
@@ -853,18 +838,18 @@ void User::CheckClass()
 
        if ((!a) || (a->GetType() == CC_DENY))
        {
-               User::QuitUser(ServerInstance, this, "Unauthorised connection");
+               ServerInstance->Users->QuitUser(this, "Unauthorised connection");
                return;
        }
        else if ((a->GetMaxLocal()) && (ServerInstance->Users->LocalCloneCount(this) > a->GetMaxLocal()))
        {
-               User::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (local)");
+               ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)");
                ServerInstance->SNO->WriteToSnoMask('A', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
                return;
        }
        else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal()))
        {
-               User::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (global)");
+               ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)");
                ServerInstance->SNO->WriteToSnoMask('A', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
                return;
        }
@@ -892,7 +877,7 @@ void User::FullConnect()
         */
        if (this->MyClass && !this->MyClass->GetPass().empty() && !this->haspassed)
        {
-               User::QuitUser(ServerInstance, this, "Invalid password");
+               ServerInstance->Users->QuitUser(this, "Invalid password");
                return;
        }
 
@@ -989,46 +974,29 @@ void User::InvalidateCache()
 
 bool User::ForceNickChange(const char* newnick)
 {
-       /*
-        * XXX this makes no sense..
-        * why do we do nothing for change on users not REG_ALL?
-        * why do we trigger events twice for everyone previously (and just them now)
-        * i think the first if () needs removing totally, or? -- w00t
-        */
-       if (this->registered != REG_ALL)
-       {
-               int MOD_RESULT = 0;
+       int MOD_RESULT = 0;
 
-               this->InvalidateCache();
+       this->InvalidateCache();
 
-               FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
+       FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
 
-               if (MOD_RESULT)
-               {
-                       ServerInstance->stats->statsCollisions++;
-                       return false;
-               }
-
-               if (ServerInstance->XLines->MatchesLine("Q",newnick))
-               {
-                       ServerInstance->stats->statsCollisions++;
-                       return false;
-               }
+       if (MOD_RESULT)
+       {
+               ServerInstance->stats->statsCollisions++;
+               return false;
        }
-       else
+
+       std::deque<classbase*> dummy;
+       Command* nickhandler = ServerInstance->Parser->GetHandler("NICK");
+       if (nickhandler) // wtfbbq, when would this not be here
        {
-               std::deque<classbase*> dummy;
-               Command* nickhandler = ServerInstance->Parser->GetHandler("NICK");
-               if (nickhandler) // wtfbbq, when would this not be here
-               {
-                       nickhandler->HandleInternal(1, dummy);
-                       bool result = (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
-                       nickhandler->HandleInternal(0, dummy);
-                       return result;
-               }
+               nickhandler->HandleInternal(1, dummy);
+               bool result = (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
+               nickhandler->HandleInternal(0, dummy);
+               return result;
        }
 
-       // Unreachable.
+       // Unreachable, we hope
        return false;
 }
 
@@ -1104,7 +1072,7 @@ int User::GetProtocolFamily()
  * XXX the duplication here is horrid..
  * do we really need two methods doing essentially the same thing?
  */
-const char* User::GetIPString()
+const char* User::GetIPString(bool translate4in6)
 {
        static char buf[1024];
 
@@ -1128,6 +1096,12 @@ const char* User::GetIPString()
                        {
                                strlcpy(&temp[1], buf, sizeof(temp) - 1);
                                *temp = '0';
+                               if (translate4in6 && !strncmp(temp, "0::ffff:", 8))
+                               {
+                                       this->cachedip = temp + 8;
+                                       return temp + 8;
+                               }
+
                                this->cachedip = temp;
                                return temp;
                        }
@@ -1865,7 +1839,7 @@ void User::HandleEvent(EventType et, int errornum)
        {
                if (!WriteError.empty())
                {
-                       User::QuitUser(ServerInstance, this, GetWriteError());
+                       ServerInstance->Users->QuitUser(this, GetWriteError());
                }
        }
 }