1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __RESOLVERS__H__
15 #define __RESOLVERS__H__
20 #include "../transport.h"
25 /** Handle resolving of server IPs for the cache
27 class SecurityIPResolver : public Resolver
31 SpanningTreeUtilities* Utils;
36 SecurityIPResolver(Module* me, SpanningTreeUtilities* U, const std::string &hostname, Link x, bool &cached, QueryType qt)
37 : Resolver(hostname, qt, cached, me), MyLink(x), Utils(U), mine(me), host(hostname), query(qt)
41 void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
43 Utils->ValidIPs.push_back(result);
46 void OnError(ResolverError e, const std::string &errormessage)
48 if (query == DNS_QUERY_AAAA)
51 SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, host, MyLink, cached, DNS_QUERY_A);
52 ServerInstance->AddResolver(res, cached);
55 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Could not resolve IP associated with Link '%s': %s",MyLink.Name.c_str(),errormessage.c_str());
59 /** This class is used to resolve server hostnames during /connect and autoconnect.
60 * As of 1.1, the resolver system is seperated out from BufferedSocket, so we must do this
61 * resolver step first ourselves if we need it. This is totally nonblocking, and will
62 * callback to OnLookupComplete or OnError when completed. Once it has completed we
63 * will have an IP address which we can then use to continue our connection.
65 class ServernameResolver : public Resolver
68 /** A copy of the Link tag info for what we're connecting to.
69 * We take a copy, rather than using a pointer, just in case the
70 * admin takes the tag away and rehashes while the domain is resolving.
73 SpanningTreeUtilities* Utils;
77 Autoconnect* myautoconnect;
79 ServernameResolver(Module* me, SpanningTreeUtilities* Util, const std::string &hostname, Link x, bool &cached, QueryType qt, Autoconnect* myac);
80 void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached);
81 void OnError(ResolverError e, const std::string &errormessage);