]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/resolvers.h
Make VF_OPTCOMMON module mismatches a fatal link error by default
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / resolvers.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __RESOLVERS__H__
15 #define __RESOLVERS__H__
16
17 #include "commands/cmd_whois.h"
18 #include "commands/cmd_stats.h"
19 #include "socket.h"
20 #include "inspircd.h"
21 #include "xline.h"
22 #include "../transport.h"
23
24 #include "utils.h"
25 #include "link.h"
26
27 /** Handle resolving of server IPs for the cache
28  */
29 class SecurityIPResolver : public Resolver
30 {
31  private:
32         Link MyLink;
33         SpanningTreeUtilities* Utils;
34         Module* mine;
35         std::string host;
36         QueryType query;
37  public:
38         SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt)
39                 : Resolver(Instance, hostname, qt, cached, me), MyLink(x), Utils(U), mine(me), host(hostname), query(qt)
40         {
41         }
42
43         void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
44         {
45                 Utils->ValidIPs.push_back(result);
46         }
47
48         void OnError(ResolverError e, const std::string &errormessage)
49         {
50                 if (query == DNS_QUERY_AAAA)
51                 {
52                         bool cached;
53                         SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, ServerInstance, host, MyLink, cached, DNS_QUERY_A);
54                         ServerInstance->AddResolver(res, cached);
55                         return;
56                 }
57                 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Could not resolve IP associated with Link '%s': %s",MyLink.Name.c_str(),errormessage.c_str());
58         }
59 };
60
61 /** This class is used to resolve server hostnames during /connect and autoconnect.
62  * As of 1.1, the resolver system is seperated out from BufferedSocket, so we must do this
63  * resolver step first ourselves if we need it. This is totally nonblocking, and will
64  * callback to OnLookupComplete or OnError when completed. Once it has completed we
65  * will have an IP address which we can then use to continue our connection.
66  */
67 class ServernameResolver : public Resolver
68 {
69  private:
70         /** A copy of the Link tag info for what we're connecting to.
71          * We take a copy, rather than using a pointer, just in case the
72          * admin takes the tag away and rehashes while the domain is resolving.
73          */
74         Link MyLink;
75         SpanningTreeUtilities* Utils;
76         QueryType query;
77         std::string host;
78         Module* mine;
79  public:
80         ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt);
81         void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached);
82         void OnError(ResolverError e, const std::string &errormessage);
83 };
84
85 #endif