]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/resolvers.h
core_hostname_lookup: find answer record of the correct type instead of assuming...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / resolvers.h
index 0ba9d6bd6b81277fcd3b570291604fc1687284d2..782ac86efeebfa47172d860044aafe4ef7499066 100644 (file)
@@ -1 +1,61 @@
-/*       +------------------------------------+\r *       | Inspire Internet Relay Chat Daemon |\r *       +------------------------------------+\r *\r *  InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r *            the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#ifndef __RESOLVERS__H__\r#define __RESOLVERS__H__\r\r#include "configreader.h"\r#include "users.h"\r#include "channels.h"\r#include "modules.h"\r#include "commands/cmd_whois.h"\r#include "commands/cmd_stats.h"\r#include "socket.h"\r#include "inspircd.h"\r#include "wildcard.h"\r#include "xline.h"\r#include "transport.h"\r\r#include "m_spanningtree/utils.h"\r#include "m_spanningtree/link.h"\r\r/** Handle resolving of server IPs for the cache\r */\rclass SecurityIPResolver : public Resolver\r{\r private:\r     Link MyLink;\r   SpanningTreeUtilities* Utils;\r  Module* mine;\r  std::string host;\r      QueryType query;\r public:\r      SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt)\r          : Resolver(Instance, hostname, qt, cached, me), MyLink(x), Utils(U), mine(me), host(hostname), query(qt)\r       {\r      }\r\r     void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)\r        {\r              Utils->ValidIPs.push_back(result);\r     }\r\r     void OnError(ResolverError e, const std::string &errormessage)\r {\r              if (query == DNS_QUERY_AAAA)\r           {\r                      bool cached;\r                   SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, ServerInstance, host, MyLink, cached, DNS_QUERY_A);\r                      ServerInstance->AddResolver(res, cached);\r                      return;\r                }\r              ServerInstance->Log(DEFAULT,"Could not resolve IP associated with Link '%s': %s",MyLink.Name.c_str(),errormessage.c_str());\r    }\r};\r\r/** This class is used to resolve server hostnames during /connect and autoconnect.\r * As of 1.1, the resolver system is seperated out from InspSocket, so we must do this\r * resolver step first ourselves if we need it. This is totally nonblocking, and will\r * callback to OnLookupComplete or OnError when completed. Once it has completed we\r * will have an IP address which we can then use to continue our connection.\r */\rclass ServernameResolver : public Resolver\r{\r private:\r        /** A copy of the Link tag info for what we're connecting to.\r         * We take a copy, rather than using a pointer, just in case the\r         * admin takes the tag away and rehashes while the domain is resolving.\r         */\r        Link MyLink;\r        SpanningTreeUtilities* Utils;\r       QueryType query;\r       std::string host;\r      Module* mine;\r public:\r        ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt);\r        void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached);\r        void OnError(ResolverError e, const std::string &errormessage);\r};\r\r#endif\r
\ No newline at end of file
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "inspircd.h"
+#include "modules/dns.h"
+
+#include "utils.h"
+#include "link.h"
+
+/** Handle resolving of server IPs for the cache
+ */
+class SecurityIPResolver : public DNS::Request
+{
+ private:
+       reference<Link> MyLink;
+       Module* mine;
+       std::string host;
+       DNS::QueryType query;
+ public:
+       SecurityIPResolver(Module* me, DNS::Manager* mgr, const std::string& hostname, Link* x, DNS::QueryType qt);
+       void OnLookupComplete(const DNS::Query *r) CXX11_OVERRIDE;
+       void OnError(const DNS::Query *q) CXX11_OVERRIDE;
+};
+
+/** This class is used to resolve server hostnames during /connect and autoconnect.
+ * As of 1.1, the resolver system is seperated out from BufferedSocket, so we must do this
+ * resolver step first ourselves if we need it. This is totally nonblocking, and will
+ * callback to OnLookupComplete or OnError when completed. Once it has completed we
+ * will have an IP address which we can then use to continue our connection.
+ */
+class ServernameResolver : public DNS::Request
+{
+ private:
+       DNS::QueryType query;
+       std::string host;
+       reference<Link> MyLink;
+       reference<Autoconnect> myautoconnect;
+ public:
+       ServernameResolver(DNS::Manager* mgr, const std::string& hostname, Link* x, DNS::QueryType qt, Autoconnect* myac);
+       void OnLookupComplete(const DNS::Query *r) CXX11_OVERRIDE;
+       void OnError(const DNS::Query *q) CXX11_OVERRIDE;
+};