]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Added <options:notimesync> to the example config
[user/henk/code/inspircd.git] / src / dns.cpp
index ca08b93ba8063e0a902ab72f86a44bb208722b6a..3381c18fa000e3886cb7e86d6ff058f418d4410a 100644 (file)
@@ -94,12 +94,12 @@ class DNSHeader
 class DNSRequest
 {
  public:
-       unsigned char   id[2];          /* Request id */
-       unsigned char*  res;            /* Result processing buffer */
+       unsigned char   id[2];          /* Request id */
+       unsigned char*  res;            /* Result processing buffer */
        unsigned int    rr_class;       /* Request class */
-       QueryType       type;           /* Request type */
+       QueryType       type;           /* Request type */
        insp_inaddr     myserver;       /* DNS server address*/
-       DNS*            dnsobj;         /* DNS caller (where we get our FD from) */
+       DNS*            dnsobj;         /* DNS caller (where we get our FD from) */
 
        DNSRequest(InspIRCd* Instance, DNS* dns, insp_inaddr server, int id, requestlist &requests);
        ~DNSRequest();
@@ -114,7 +114,7 @@ class RequestTimeout : public InspTimer
        int watchid;
        requestlist &rl;
  public:
-       RequestTimeout(InspIRCd* SI, DNSRequest* watching, int id, requestlist &requests) : InspTimer(2, time(NULL)), ServerInstance(SI), watch(watching), watchid(id), rl(requests)
+       RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id, requestlist &requests) : InspTimer(n, time(NULL)), ServerInstance(SI), watch(watching), watchid(id), rl(requests)
        {
                ServerInstance->Log(DEBUG, "New DNS timeout set on %08x", watching);
        }
@@ -126,7 +126,12 @@ class RequestTimeout : public InspTimer
                        /* Still exists, whack it */
                        if (rl.find(watchid)->second == watch)
                        {
-                               watch->OnError(RESOLVER_TIMEOUT, "Request timed out");
+                               if (ServerInstance->Res->Classes[watchid])
+                               {
+                                       ServerInstance->Res->Classes[watchid]->OnError(RESOLVER_TIMEOUT, "Request timed out");
+                                       delete ServerInstance->Res->Classes[watchid];
+                                       ServerInstance->Res->Classes[watchid] = NULL;
+                               }
                                rl.erase(rl.find(watchid));
                                delete watch;
                                ServerInstance->Log(DEBUG, "DNS timeout on %08x squished pointer", watch);
@@ -143,7 +148,7 @@ DNSRequest::DNSRequest(InspIRCd* Instance, DNS* dns, insp_inaddr server, int id,
        res = new unsigned char[512];
        *res = 0;
        memcpy(&myserver, &server, sizeof(insp_inaddr));
-       RequestTimeout* RT = new RequestTimeout(Instance, this, id, requests);
+       RequestTimeout* RT = new RequestTimeout(Instance->Config->dns_timeout ? Instance->Config->dns_timeout : 5, Instance, this, id, requests);
        Instance->Timers->AddTimer(RT); /* The timer manager frees this */
 }
 
@@ -463,10 +468,15 @@ int DNS::GetName(const insp_inaddr *ip)
        int length;
 
 #ifdef IPV6
-       DNS::MakeIP6Int(query, (in6_addr*)ip);
+       unsigned char* c = (unsigned char*)&ip->s6_addr;
+       if (c[0] == 0 && c[1] == 0 && c[2] == 0 && c[3] == 0 &&
+           c[4] == 0 && c[5] == 0 && c[6] == 0 && c[7] == 0 &&
+           c[8] == 0 && c[9] == 0 && c[10] == 0xFF && c[11] == 0xFF)
+               sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[15],c[14],c[13],c[12]);
+       else
+               DNS::MakeIP6Int(query, (in6_addr*)ip);
 #else
        unsigned char* c = (unsigned char*)&ip->s_addr;
-
        sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[3],c[2],c[1],c[0]);
 #endif
 
@@ -939,7 +949,7 @@ int Resolver::GetId()
 }
 
 /** Process a socket read event */
-void DNS::HandleEvent(EventType et)
+void DNS::HandleEvent(EventType et, int errornum)
 {
        ServerInstance->Log(DEBUG,"Marshall reads: %d",this->GetFd());
        /* Fetch the id and result of the next available packet */