summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-06 18:32:32 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-06 18:32:32 +0000
commit6cba4035015b2f00eff989708131933bd2d51226 (patch)
treee72d96c17099ca0bc5b2f58c839ffcf1d76ebc78
parentfa16e59314dda5ddb70959a595deb92642821c97 (diff)
Fix resolving of security ips to allow for ipv4 resolution when built for ipv6
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6520 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_spanningtree/resolvers.h13
-rw-r--r--src/modules/m_spanningtree/utils.cpp27
2 files changed, 35 insertions, 5 deletions
diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h
index 0efa8113f..3828985d4 100644
--- a/src/modules/m_spanningtree/resolvers.h
+++ b/src/modules/m_spanningtree/resolvers.h
@@ -23,9 +23,12 @@ class SecurityIPResolver : public Resolver
private:
Link MyLink;
SpanningTreeUtilities* Utils;
+ Module* mine;
+ std::string host;
+ QueryType query;
public:
- SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached)
- : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), MyLink(x), Utils(U)
+ SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached, QueryType qt)
+ : Resolver(Instance, hostname, qt, cached, me), MyLink(x), Utils(U), mine(me), host(hostname), query(qt)
{
}
@@ -36,6 +39,12 @@ class SecurityIPResolver : public Resolver
void OnError(ResolverError e, const std::string &errormessage)
{
+ if (query == DNS_QUERY_AAAA)
+ {
+ bool cached;
+ SecurityIPResolver* res = new SecurityIPResolver(mine, Utils, ServerInstance, host, MyLink, cached, DNS_QUERY_A);
+ ServerInstance->AddResolver(res, cached);
+ }
ServerInstance->Log(DEFAULT,"Could not resolve IP associated with Link '%s': %s",MyLink.Name.c_str(),errormessage.c_str());
}
};
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 02a014425..c21a61599 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -415,13 +415,34 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
ValidIPs.push_back(Allow);
/* Needs resolving */
- insp_inaddr binip;
- if (insp_aton(L.IPAddr.c_str(), &binip) < 1)
+ bool ipvalid = true;
+ QueryType start_type = DNS_QUERY_A;
+#ifdef IPV6
+ start_type = DNS_QUERY_AAAA;
+ if (strchr(L.IPAddr.c_str(),':'))
+ {
+ in6_addr n;
+ if (inet_pton(AF_INET6, L.IPAddr.c_str(), &n) < 1)
+ ipvalid = false;
+ }
+ else
+ {
+ in_addr n;
+ if (inet_aton(L.IPAddr.c_str(),&n) < 1)
+ ipvalid = false;
+ }
+#else
+ in_addr n;
+ if (inet_aton(L.IPAddr.c_str(),&n) < 1)
+ ipvalid = false;
+#endif
+
+ if (!ipvalid)
{
try
{
bool cached;
- SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached);
+ SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached, start_type);
ServerInstance->AddResolver(sr, cached);
}
catch (ModuleException& e)