From 14556541bb12fda6e7af8273458f680386e9c438 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 16 Aug 2016 12:43:40 -0400 Subject: core_dns Make question a member of request, move common FindAnswerOfType to be a member of query --- include/modules/dns.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/modules/dns.h b/include/modules/dns.h index 1ba54cc61..5f2836761 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -117,6 +117,18 @@ namespace DNS Query() : error(ERROR_NONE), cached(false) { } Query(const Question& q) : question(q), error(ERROR_NONE), cached(false) { } + + const ResourceRecord* FindAnswerOfType(QueryType qtype) const + { + for (std::vector::const_iterator i = answers.begin(); i != answers.end(); ++i) + { + const DNS::ResourceRecord& rr = *i; + if (rr.type == qtype) + return &rr; + } + + return NULL; + } }; class ReplySocket; @@ -136,11 +148,12 @@ namespace DNS /** A DNS query. */ - class Request : public Timer, public Question + class Request : public Timer { protected: Manager* const manager; public: + Question question; /* Use result cache if available */ bool use_cache; /* Request id */ @@ -150,8 +163,8 @@ namespace DNS Request(Manager* mgr, Module* mod, const std::string& addr, QueryType qt, bool usecache = true) : Timer((ServerInstance->Config->dns_timeout ? ServerInstance->Config->dns_timeout : 5)) - , Question(addr, qt) , manager(mgr) + , question(addr, qt) , use_cache(usecache) , id(0) , creator(mod) @@ -178,7 +191,7 @@ namespace DNS */ bool Tick(time_t now) { - Query rr(*this); + Query rr(this->question); rr.error = ERROR_TIMEDOUT; this->OnError(&rr); delete this; -- cgit v1.2.3