summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/dns.h6
-rw-r--r--src/dns.cpp14
2 files changed, 18 insertions, 2 deletions
diff --git a/include/dns.h b/include/dns.h
index 6913527ae..54cdf5672 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -337,7 +337,11 @@ class DNS : public EventHandler
/**
* Server address being used currently
*/
- insp_inaddr myserver;
+ int socketfamily;
+#ifdef IPV6
+ in6_addr myserver6;
+#endif
+ in_addr myserver4;
/**
* A counter used to form part of the pseudo-random id
diff --git a/src/dns.cpp b/src/dns.cpp
index ac6097cd2..ea6b000a9 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -291,7 +291,6 @@ int DNS::PruneCache()
void DNS::Rehash()
{
- insp_inaddr addr;
ip6munge = false;
if (this->GetFd() > -1)
@@ -319,6 +318,19 @@ void DNS::Rehash()
this->ip6munge = true;
}
+ this->socketfamily = AF_INET;
+#ifdef IPV6
+ if (strchr(ServerInstance->Config->DNSServer,':'))
+ {
+ this->socketfamily = AF_INET6;
+ inet_pton(AF_INET6, &this->myserver6, ServerInstance->Config->DNSServer);
+ }
+ else
+ inet_aton(&this->myserver4, ServerInstance->Config->DNSServer);
+#else
+ inet_aton(&this->myserver4, ServerInstance->Config->DNSServer);
+#endif
+
/* Initialize mastersocket */
int s = OpenTCPSocket(ServerInstance->Config->DNSServer, SOCK_DGRAM);
this->SetFd(s);