X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fuser_resolver.cpp;h=0218f32690bcf78803d55bc3403e2783b82b398e;hb=3954761f11af50ed33b88f1e6609bfa8a5dab750;hp=bd27d63503871d6d47b6c05af170d1ea2aa84246;hpb=f209cce90b394acd26e22eacef0bff61e8f5b4e1;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/user_resolver.cpp b/src/user_resolver.cpp index bd27d6350..0218f3269 100644 --- a/src/user_resolver.cpp +++ b/src/user_resolver.cpp @@ -3,7 +3,7 @@ * +------------------------------------+ * * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -63,9 +63,31 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)) { /* Both lookups completed */ - std::string result2("0::ffff:"); - result2.append(result); - if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2) + + sockaddr* user_ip = this->bound_user->ip; + bool rev_match = false; +#ifdef IPV6 + if (user_ip->sa_family == AF_INET6) + { + struct in6_addr res_bin; + if (inet_pton(AF_INET6, result.c_str(), &res_bin)) + { + sockaddr_in6* user_ip6 = reinterpret_cast(user_ip); + rev_match = !memcmp(&user_ip6->sin6_addr, &res_bin, sizeof(res_bin)); + } + } + else +#endif + { + struct in_addr res_bin; + if (inet_pton(AF_INET, result.c_str(), &res_bin)) + { + sockaddr_in* user_ip4 = reinterpret_cast(user_ip); + rev_match = !memcmp(&user_ip4->sin_addr, &res_bin, sizeof(res_bin)); + } + } + + if (rev_match) { std::string hostname = this->bound_user->stored_host; if (hostname.length() < 65)