]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix for bug typo, dont let it creep into the release!
[user/henk/code/inspircd.git] / src / users.cpp
index 11d1cf130f8ca3fe13b2ef976cca2e6991071519..59d19adff0dec4a77ef299b9897d2f66de0062bf 100644 (file)
@@ -210,7 +210,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
                        if (hostname.length() < 65)
                        {
                                /* Check we didnt time out */
-                               if (this->bound_user->registered != REG_ALL)
+                               if ((this->bound_user->registered != REG_ALL) && (!this->bound_user->dns_done))
                                {
                                        /* Hostnames starting with : are not a good thing (tm) */
                                        if (*(hostname.c_str()) == ':')
@@ -226,12 +226,20 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
                        }
                        else
                        {
-                               this->bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", this->bound_user->GetIPString());
+                               if (!this->bound_user->dns_done)
+                               {
+                                       this->bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", this->bound_user->GetIPString());
+                                       this->bound_user->dns_done = true;
+                               }
                        }
                }
                else
                {
-                       this->bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", this->bound_user->GetIPString());
+                       if (!this->bound_user->dns_done)
+                       {
+                               this->bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", this->bound_user->GetIPString());
+                               this->bound_user->dns_done = true;
+                       }
                }
        }
 }
@@ -240,9 +248,14 @@ void UserResolver::OnError(ResolverError e, const std::string &errormessage)
 {
        if (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)
        {
-               /* Error message here */
-               this->bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), this->bound_user->GetIPString());
-               this->bound_user->dns_done = true;
+               /* Since dns timeout is implemented outside of the resolver, this was a race condition that could result in this message being sent *after*
+                * the user was fully connected. This check fixes that issue  - Special */
+               if (!this->bound_user->dns_done)
+               {
+                       /* Error message here */
+                       this->bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), this->bound_user->GetIPString());
+                       this->bound_user->dns_done = true;
+               }
        }
 }
 
@@ -325,6 +338,7 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
        sendq = "";
        WriteError = "";
        res_forward = res_reverse = NULL;
+       Visibility = NULL;
        ip = NULL;
        chans.clear();
        invites.clear();
@@ -417,7 +431,6 @@ char* userrec::MakeHostIP()
 
 void userrec::CloseSocket()
 {
-       ServerInstance->Log(DEBUG,"Close user socket %d", this->fd);
        shutdown(this->fd,2);
        close(this->fd);
 }
@@ -992,14 +1005,14 @@ void userrec::FullConnect()
                return;
        }
 
-       if (this->LocalCloneCount() > a->GetMaxLocal())
+       if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
        {
                this->muted = true;
                ServerInstance->GlobalCulls.AddItem(this, "No more connections allowed from your host via this connect class (local)");
                ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
                return;
        }
-       else if (this->GlobalCloneCount() > a->GetMaxGlobal())
+       else if ((a->GetMaxGlobal()) && (this->GlobalCloneCount() > a->GetMaxGlobal()))
        {
                this->muted = true;
                ServerInstance->GlobalCulls.AddItem(this, "No more connections allowed from your host via this connect class (global)");
@@ -1807,8 +1820,18 @@ ConnectClass* userrec::GetClass()
 {
        for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
        {
-               if ((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str())))
-                       return &(*i);
+               if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
+               {
+                       if (i->GetPort())
+                       {
+                               if (this->GetPort() == i->GetPort())
+                                       return &(*i);
+                               else
+                                       continue;
+                       }
+                       else
+                               return &(*i);
+               }
        }
        return NULL;
 }
@@ -1930,4 +1953,16 @@ const char* userrec::GetOperQuit()
        return operquit ? operquit : "";
 }
 
+VisData::VisData()
+{
+}
+
+VisData::~VisData()
+{
+}
+
+bool VisData::VisibleTo(userrec* user)
+{
+       return true;
+}