summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-09-08 16:58:50 -0400
committerAdam <Adam@anope.org>2014-09-08 18:19:00 -0400
commitdf67ab549bcc2cd53519f309110c58c00f2c935b (patch)
tree39bccb74584d359ef8540c3ee6df44dc34093d20 /src/dns.cpp
parent8125a187b17f41a199cc4ebaa99f4d616e930049 (diff)
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
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp10
1 files changed, 6 insertions, 4 deletions
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];