]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Add 'no such server' on remote stats to invalid name
[user/henk/code/inspircd.git] / src / dns.cpp
index 907ded7f22d2eb474c6885758ce8efcece987dc8..0436095b6bd30afc315837138fd0f7402a4c1891 100644 (file)
@@ -257,11 +257,16 @@ DNS::DNS()
        if (insp_aton(Config->DNSServer,&addr) > 0)
        {
                memcpy(&myserver,&addr,sizeof(insp_inaddr));
-               if (strstr(Config->DNSServer,"::ffff:") == (char*)&Config->DNSServer)
+               if ((strstr(Config->DNSServer,"::ffff:") == (char*)&Config->DNSServer) ||  (strstr(Config->DNSServer,"::FFFF:") == (char*)&Config->DNSServer))
                {
-                       /* These dont come back looking like they did when they went in. Reformat them */
-                       log(DEBUG,"Munging dns server name");
-                       strcpy(Config->DNSServer,insp_ntoa(myserver));
+                       /* These dont come back looking like they did when they went in.
+                        * We're forced to turn some checks off.
+                        * If anyone knows how to fix this, let me know. --Brain
+                        */
+                       log(DEFAULT,"WARNING: Using IPv4 addresses over IPv6 forces some DNS checks to be disabled.");
+                       log(DEFAULT,"         This should not cause a problem, however it is recommended you migrate");
+                       log(DEFAULT,"         to a true IPv6 environment.");
+                       this->ip6munge = true;
                }
                log(DEBUG,"Added nameserver '%s'",Config->DNSServer);
        }
@@ -448,7 +453,7 @@ int DNS::GetNameForce(const char *ip, ForceProtocol fp)
        DNSHeader h;
        int id;
        int length;
-
+#ifdef SUPPORT_IP6LINKS
        if (fp == PROTOCOL_IPV6)
        {
                in6_addr i;
@@ -461,6 +466,7 @@ int DNS::GetNameForce(const char *ip, ForceProtocol fp)
                        return -1;
        }
        else
+#endif
        {
                in_addr i;
                if (inet_aton(ip, &i))
@@ -488,6 +494,7 @@ int DNS::GetNameForce(const char *ip, ForceProtocol fp)
 
 void DNS::MakeIP6Int(char* query, const in6_addr *ip)
 {
+#ifdef SUPPORT_IP6LINKS
        const char* hex = "0123456789abcdef";
        for (int index = 31; index >= 0; index--) /* for() loop steps twice per byte */
        {
@@ -500,6 +507,9 @@ void DNS::MakeIP6Int(char* query, const in6_addr *ip)
                *query++ = '.'; /* Seperator */
        }
        strcpy(query,"ip6.arpa"); /* Suffix the string */
+#else
+       *query = 0;
+#endif
 }
 
 /* Return the next id which is ready, and the result attached to it */
@@ -547,7 +557,7 @@ DNSResult DNS::GetResult()
        /* We cant perform this security check if you're using 4in6.
         * Tough luck to you, choose one or't other!
         */
-       if (strstr(Config->DNSServer,"::ffff:") != (char*)&Config->DNSServer)
+       if (!ip6munge)
        {
                if ((port_from != DNS::QUERY_PORT) || (strcasecmp(ipaddr_from, Config->DNSServer)))
                {
@@ -635,6 +645,14 @@ DNSResult DNS::GetResult()
                                                memmove(formatted,formatted + 1, strlen(formatted + 1) + 1);
                                }
                                resultstr = formatted;
+
+                               /* Special case. Sending ::1 around between servers
+                                * and to clients is dangerous, because the : on the
+                                * start makes the client or server interpret the IP
+                                * as the last parameter on the line with a value ":1".
+                                */
+                               if (*formatted == ':')
+                                       resultstr = "0" + resultstr;
                        }
                        break;