X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fuser_resolver.cpp;h=9c530506dfa412d985e1dd2c397b1236406639bf;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=156bb9828f6384211d1b1e40b6b7b9bdfa87c54a;hpb=69e28c67dddd8b74ee4c321667d286111e09e5da;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/user_resolver.cpp b/src/user_resolver.cpp index 156bb9828..9c530506d 100644 --- a/src/user_resolver.cpp +++ b/src/user_resolver.cpp @@ -1,16 +1,23 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2007 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" UserResolver::UserResolver(LocalUser* user, std::string to_resolve, QueryType qt, bool &cache) : Resolver(to_resolve, qt, cache, NULL), uuid(user->uuid) @@ -22,9 +29,17 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, { UserResolver *res_forward; // for forward-resolution LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid); + if (!bound_user) + { + ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG, "Resolution finished for user '%s' who is gone", uuid.c_str()); + return; + } + + ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG, "DNS result for %s: '%s' -> '%s'", uuid.c_str(), input.c_str(), result.c_str()); - if ((!this->fwd) && bound_user) + if (!fwd) { + // first half of resolution is done. We now need to verify that the host matches. bound_user->stored_host = result; try { @@ -47,10 +62,10 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, } catch (CoreException& e) { - ServerInstance->Logs->Log("RESOLVER", DEBUG,"Error in resolver: %s",e.GetReason()); + ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG,"Error in resolver: %s",e.GetReason()); } } - else if ((this->fwd) && bound_user) + else { /* Both lookups completed */ @@ -72,7 +87,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, rev_match = !memcmp(&user_ip->in4.sin_addr, &res_bin, sizeof(res_bin)); } } - + if (rev_match) { std::string hostname = bound_user->stored_host; @@ -97,7 +112,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, { if (!bound_user->dns_done) { - bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString()); + bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); bound_user->dns_done = true; } } @@ -106,7 +121,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, { if (!bound_user->dns_done) { - bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString()); + bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); bound_user->dns_done = true; } } @@ -121,7 +136,7 @@ void UserResolver::OnError(ResolverError e, const std::string &errormessage) LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid); if (bound_user) { - bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), bound_user->GetIPString()); + bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), bound_user->GetIPString().c_str()); bound_user->dns_done = true; bound_user->stored_host.resize(0); ServerInstance->stats->statsDnsBad++;