From 66da4ef77e9d22370ebfbab014abe5acefce35f4 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 3 Feb 2007 18:38:31 +0000 Subject: On ipv6 servers, if a user connects with 4in6 (0::ffff:...) then attempt a dnsbl lookup of their ip (the bit after the 0::ffff:) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6484 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_dnsbl.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 213c2f67e..6ea05e6fa 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -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::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; -- cgit v1.2.3