]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Create StreamSocket for IO hooking implementation
[user/henk/code/inspircd.git] / src / dns.cpp
index 396cc56df258fdb5c69eca8c88975fc219405521..94a01e64c9cedbf60bfa70c3dfaee096bf07adce 100644 (file)
@@ -34,7 +34,6 @@ looks like this, walks like this or tastes like this.
 #include "inspircd_se_config.h"
 #endif
 
-#include "dns.h"
 #include "inspircd.h"
 #include "socketengine.h"
 #include "configreader.h"
@@ -129,6 +128,11 @@ class RequestTimeout : public Timer
        RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, SI->Time()), ServerInstance(SI), watch(watching), watchid(id)
        {
        }
+       ~RequestTimeout()
+       {
+               if (ServerInstance->Res)
+                       Tick(0);
+       }
 
        void Tick(time_t)
        {
@@ -143,7 +147,6 @@ class RequestTimeout : public Timer
                        }
                        ServerInstance->Res->requests[watchid] = NULL;
                        delete watch;
-                       return;
                }
        }
 };
@@ -217,7 +220,6 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
 
        DNS::EmptyHeader(payload,header,length);
 
-#ifdef IPV6
        if (this->dnsobj->socketfamily == AF_INET6)
        {
                sockaddr_in6 addr;
@@ -229,7 +231,6 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
                        return -1;
        }
        else
-#endif
        {
                sockaddr_in addr;
                memset(&addr,0,sizeof(addr));
@@ -334,7 +335,6 @@ void DNS::Rehash()
        }
 
        this->socketfamily = AF_INET;
-#ifdef IPV6
        if (strchr(ServerInstance->Config->DNSServer,':'))
        {
                this->socketfamily = AF_INET6;
@@ -345,9 +345,6 @@ void DNS::Rehash()
                inet_aton(ServerInstance->Config->DNSServer, &this->myserver4);
                portpass = -1;
        }
-#else
-       inet_aton(ServerInstance->Config->DNSServer, &this->myserver4);
-#endif
 
        /* Initialize mastersocket */
        int s = irc::sockets::OpenTCPSocket(ServerInstance->Config->DNSServer, SOCK_DGRAM);
@@ -602,7 +599,6 @@ DNSResult DNS::GetResult()
         *
         * -- Thanks jilles for pointing this one out.
         */
-#ifdef IPV6
        char nbuf[MAXBUF];
        if (this->socketfamily == AF_INET6)
        {
@@ -610,7 +606,6 @@ DNSResult DNS::GetResult()
                port_from = ntohs(from.in6.sin6_port);
        }
        else
-#endif
        {
                ipaddr_from = inet_ntoa(from.in4.sin_addr);
                port_from = ntohs(from.in4.sin_port);
@@ -884,6 +879,8 @@ DNS::~DNS()
        ServerInstance->SE->Shutdown(this, 2);
        ServerInstance->SE->Close(this);
        ServerInstance->Timers->DelTimer(this->PruneTimer);
+       if (cache)
+               delete cache;
 }
 
 CachedQuery* DNS::GetCache(const std::string &source)