]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Add comments on Daniel's work
[user/henk/code/inspircd.git] / src / users.cpp
index 4f0476911ec8b3af0e6a3ba324c44441580b1a11..c6f5e498f9bb3013745933c8f3a9fa378d6be866 100644 (file)
@@ -101,11 +101,10 @@ void User::StartDNSLookup()
                const char* sip = this->GetIPString();
                UserResolver *res_reverse;
 
-               /* Special case for 4in6 (Have i mentioned i HATE 4in6?) */
-               if (!strncmp(sip, "0::ffff:", 8))
-                       res_reverse = new UserResolver(this->ServerInstance, this, sip + 8, DNS_QUERY_PTR4, cached);
-               else
-                       res_reverse = new UserResolver(this->ServerInstance, this, sip, this->GetProtocolFamily() == AF_INET ? DNS_QUERY_PTR4 : DNS_QUERY_PTR6, cached);
+               QueryType resolvtype = strchr(sip, ':') ? DNS_QUERY_PTR6 : DNS_QUERY_PTR4;
+               // when GetProtocolFamily() works correctly with 4in6, this can be replaced by
+               // this->GetProtocolFamily() == AF_INET ? DNS_QUERY_PTR4 : DNS_QUERY_PTR6;
+               res_reverse = new UserResolver(this->ServerInstance, this, sip, resolvtype, cached);
 
                this->ServerInstance->AddResolver(res_reverse, cached);
        }
@@ -1255,8 +1254,12 @@ const char* User::GetIPString()
                        /* IP addresses starting with a : on irc are a Bad Thing (tm) */
                        if (*buf == ':')
                        {
-                               strlcpy(&temp[1], buf, sizeof(temp) - 1);
-                               *temp = '0';
+                               if (!strncmp(buf, "::ffff:", 7) && isdigit(buf[7])) {
+                                       strlcpy(temp, buf+7, sizeof(temp) - 1);
+                               } else {
+                                       strlcpy(&temp[1], buf, sizeof(temp) - 1);
+                                       *temp = '0';
+                               }
                                this->cachedip = temp;
                                return temp;
                        }