The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

resolvers.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #ifndef __RESOLVERS__H__
00015 #define __RESOLVERS__H__
00016 
00017 #include "commands/cmd_whois.h"
00018 #include "commands/cmd_stats.h"
00019 #include "socket.h"
00020 #include "inspircd.h"
00021 #include "xline.h"
00022 #include "transport.h"
00023 
00024 #include "m_spanningtree/utils.h"
00025 #include "m_spanningtree/link.h"
00026 
00029 class SecurityIPResolver : public Resolver
00030 {
00031  private:
00032         Link MyLink;
00033         SpanningTreeUtilities* Utils;
00034         Module* mine;
00035         std::string host;
00036         QueryType query;
00037  public:
00038         SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt)
00039                 : Resolver(Instance, hostname, qt, cached, me), MyLink(x), Utils(U), mine(me), host(hostname), query(qt)
00040         {
00041         }
00042 
00043         void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached, int resultnum = 0)
00044         {
00045                 Utils->ValidIPs.push_back(result);
00046         }
00047 
00048         void OnError(ResolverError e, const std::string &errormessage)
00049         {
00050                 if (query == DNS_QUERY_AAAA)
00051                 {
00052                         bool cached;
00053                         SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, ServerInstance, host, MyLink, cached, DNS_QUERY_A);
00054                         ServerInstance->AddResolver(res, cached);
00055                         return;
00056                 }
00057                 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Could not resolve IP associated with Link '%s': %s",MyLink.Name.c_str(),errormessage.c_str());
00058         }
00059 };
00060 
00067 class ServernameResolver : public Resolver
00068 {
00069  private:
00074         Link MyLink;
00075         SpanningTreeUtilities* Utils;
00076         QueryType query;
00077         std::string host;
00078         Module* mine;
00079  public:
00080         ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt);
00081         void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached, int resultnum = 0);
00082         void OnError(ResolverError e, const std::string &errormessage);
00083 };
00084 
00085 #endif