X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdns.cpp;h=4e2a5b5a9503a79e66f996944f8ab2d2f1a4103f;hb=4d42d544584875d0d71dab99f6785ac98324b971;hp=63b523bfda98069ef9ea957007e9eb4ffc84791f;hpb=76e9dc04d73d94e178224bcda021edae2f7bed9b;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dns.cpp b/src/dns.cpp index 63b523bfd..4e2a5b5a9 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * InspIRCd: (C) 2002-2009 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -126,7 +126,7 @@ class RequestTimeout : public Timer DNSRequest* watch; int watchid; public: - RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, time(NULL)), ServerInstance(SI), watch(watching), watchid(id) + RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, SI->Time()), ServerInstance(SI), watch(watching), watchid(id) { } @@ -214,7 +214,7 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp this->rr_class = 1; this->type = qt; - + DNS::EmptyHeader(payload,header,length); #ifdef IPV6 @@ -250,7 +250,7 @@ DNSRequest* DNS::AddQuery(DNSHeader *header, int &id, const char* original) /* Is the DNS connection down? */ if (this->GetFd() == -1) return NULL; - + /* Create an id */ id = this->PRNG() & DNS::MAX_REQUEST_ID; @@ -405,7 +405,7 @@ DNS::DNS(InspIRCd* Instance) : ServerInstance(Instance) /* DNS::Rehash() sets this to a valid ptr */ this->cache = NULL; - + /* Again, DNS::Rehash() sets this to a * valid value */ @@ -463,7 +463,7 @@ int DNS::GetIP(const char *name) DNSHeader h; int id; int length; - + if ((length = this->MakePayload(name, DNS_QUERY_A, 1, (unsigned char*)&h.payload)) == -1) return -1; @@ -763,7 +763,6 @@ DNSResult DNS::GetResult(int resultnum) default: break; - } /* Build the reply with the id and hostname/ip in it */ @@ -847,7 +846,7 @@ DNSInfo DNSRequest::ResultIsReady(DNSHeader &header, int length, int result_we_w /* XXX: We actually initialise 'rr' here including its ttl field */ if (curanswer == result_we_want) DNS::FillResourceRecord(&rr,&header.payload[i]); - + i += 10; if (rr.type != this->type) { @@ -939,7 +938,7 @@ CachedQuery* DNS::GetCache(const std::string &source) else return NULL; } - + void DNS::DelCache(const std::string &source) { cache->erase(source.c_str()); @@ -1064,7 +1063,7 @@ void DNS::HandleEvent(EventType, int) res = this->GetResult(resultnum); ServerInstance->Logs->Log("RESOLVER",DEBUG,"Result %d id %d", resultnum, res.id); - + /* Is there a usable request id? */ if (res.id != -1) { @@ -1091,7 +1090,7 @@ void DNS::HandleEvent(EventType, int) { if (ServerInstance && ServerInstance->stats) ServerInstance->stats->statsDnsGood++; - + if (!this->GetCache(res.original.c_str())) this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.ttl))); @@ -1100,14 +1099,14 @@ void DNS::HandleEvent(EventType, int) Classes[res.id] = NULL; } } - + if (ServerInstance && ServerInstance->stats) ServerInstance->stats->statsDns++; } resultnum++; } - + /** Add a derived Resolver to the working set */ bool DNS::AddResolverClass(Resolver* r) { @@ -1169,5 +1168,3 @@ unsigned long DNS::PRNG() val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size(); return val; } - -