]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
On ipv6 servers, if a user connects with 4in6 (0::ffff:...) then attempt a dnsbl...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 3 Feb 2007 18:38:31 +0000 (18:38 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 3 Feb 2007 18:38:31 +0000 (18:38 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6484 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_dnsbl.cpp

index 213c2f67e4e812794b66c13905a055d442243bd3..6ea05e6fac78fb1ce61de1f5dd1eaa1969dcc1be 100644 (file)
@@ -270,13 +270,30 @@ class ModuleDNSBL : public Module
                        unsigned char a, b, c, d;
                        char reversedipbuf[128];
                        std::string reversedip;
+                       bool success = false;
 
                        if (!inet_aton(user->GetIPString(), &in))
                        {
-                               ServerInstance->WriteOpers("Invalid IP address in m_dnsbl! Bailing check");
-                               return 0;
+#ifdef IPV6
+                               /* We could have an ipv6 address here */
+                               std::string x = user->GetIPString();
+                               /* Is it a 4in6 address? (Compensate for this kernel kludge that people love) */
+                               if (x.find("0::ffff:") == x.begin())
+                               {
+                                       x.erase(x.begin(), x.begin() + 8);
+                                       if (inet_aton(x.c_str(), &in))
+                                               success = true;
+                               }
+#endif
+                       }
+                       else
+                       {
+                               success = true;
                        }
 
+                       if (!success)
+                               return 0;
+
                        d = (unsigned char) (in.s_addr >> 24) & 0xFF;
                        c = (unsigned char) (in.s_addr >> 16) & 0xFF;
                        b = (unsigned char) (in.s_addr >> 8) & 0xFF;
@@ -289,7 +306,7 @@ class ModuleDNSBL : public Module
                        for (std::vector<DNSBLConfEntry *>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++)
                        {
                                // Fill hostname with a dnsbl style host (d.c.b.a.domain.tld)
-                               std::string hostname=reversedip+"."+ (*i)->domain;
+                               std::string hostname = reversedip + "." + (*i)->domain;
 
                                /* now we'd need to fire off lookups for `hostname'. */
                                bool cached;