From df67ab549bcc2cd53519f309110c58c00f2c935b Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 8 Sep 2014 16:58:50 -0400 Subject: Do not use the result of the dns cache when the query type of the result is different from the type of the query. #66 --- src/dns.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/dns.cpp') diff --git a/src/dns.cpp b/src/dns.cpp index 63bde0ecc..8ad94e9e1 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -160,7 +160,7 @@ class RequestTimeout : public Timer } }; -CachedQuery::CachedQuery(const std::string &res, unsigned int ttl) : data(res) +CachedQuery::CachedQuery(const std::string &res, QueryType qt, unsigned int ttl) : data(res), type(qt) { expires = ServerInstance->Time() + ttl; } @@ -716,8 +716,9 @@ DNSResult DNS::GetResult() /* Build the reply with the id and hostname/ip in it */ std::string ro = req->orig; + DNSResult result = DNSResult(this_id,resultstr,ttl,ro,req->type); delete req; - return DNSResult(this_id,resultstr,ttl,ro); + return result; } } @@ -945,11 +946,12 @@ Resolver::Resolver(const std::string &source, QueryType qt, bool &cached, Module { ServerInstance->Res->DelCache(source); } - else + else if (CQ->type == qt) { cached = true; return; } + CQ = NULL; } switch (querytype) @@ -1054,7 +1056,7 @@ void DNS::HandleEvent(EventType, int) 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))); + this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.type, res.ttl))); Classes[res.id]->OnLookupComplete(res.result, res.ttl, false); delete Classes[res.id]; -- cgit v1.2.3