The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
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 "configreader.h"
00018 #include "users.h"
00019 #include "channels.h"
00020 #include "modules.h"
00021 #include "commands/cmd_whois.h"
00022 #include "commands/cmd_stats.h"
00023 #include "socket.h"
00024 #include "inspircd.h"
00025 #include "wildcard.h"
00026 #include "xline.h"
00027 #include "transport.h"
00028 
00029 #include "m_spanningtree/utils.h"
00030 #include "m_spanningtree/link.h"
00031 
00034 class SecurityIPResolver : public Resolver
00035 {
00036  private:
00037         Link MyLink;
00038         SpanningTreeUtilities* Utils;
00039         Module* mine;
00040         std::string host;
00041         QueryType query;
00042  public:
00043         SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt)
00044                 : Resolver(Instance, hostname, qt, cached, me), MyLink(x), Utils(U), mine(me), host(hostname), query(qt)
00045         {
00046         }
00047 
00048         void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
00049         {
00050                 Utils->ValidIPs.push_back(result);
00051         }
00052 
00053         void OnError(ResolverError e, const std::string &errormessage)
00054         {
00055                 if (query == DNS_QUERY_AAAA)
00056                 {
00057                         bool cached;
00058                         SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, ServerInstance, host, MyLink, cached, DNS_QUERY_A);
00059                         ServerInstance->AddResolver(res, cached);
00060                         return;
00061                 }
00062                 ServerInstance->Log(DEFAULT,"Could not resolve IP associated with Link '%s': %s",MyLink.Name.c_str(),errormessage.c_str());
00063         }
00064 };
00065 
00072 class ServernameResolver : public Resolver
00073 {
00074  private:
00079         Link MyLink;
00080         SpanningTreeUtilities* Utils;
00081         QueryType query;
00082         std::string host;
00083         Module* mine;
00084  public:
00085         ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt);
00086         void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached);
00087         void OnError(ResolverError e, const std::string &errormessage);
00088 };
00089 
00090 #endif