summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-08-16 12:43:40 -0400
committerAttila Molnar <attilamolnar@hush.com>2016-08-25 17:12:48 +0200
commit14556541bb12fda6e7af8273458f680386e9c438 (patch)
tree4b5f1855562785fbfe669794710e6da9a7d2b08f /include
parent5c1b64735597e11f2336302ede671e5060f576ff (diff)
core_dns Make question a member of request, move common FindAnswerOfType to be a member of query
Diffstat (limited to 'include')
-rw-r--r--include/modules/dns.h19
1 files changed, 16 insertions, 3 deletions
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<DNS::ResourceRecord>::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;