X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules%2Fdns.h;h=3db651798e0028267b8f91279a353ab4dbb382ba;hb=65f74be719bf249f4bc93e09670ee07410ecec96;hp=1ba54cc616375fcfed8d4d26b75b25607b617d77;hpb=70542e525b343c3341fb1b8ef7ffe886916f73cd;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules/dns.h b/include/modules/dns.h index 1ba54cc61..3db651798 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -33,6 +33,8 @@ namespace DNS QUERY_CNAME = 5, /* Reverse DNS lookup */ QUERY_PTR = 12, + /* TXT */ + QUERY_TXT = 16, /* IPv6 AAAA lookup */ QUERY_AAAA = 28 }; @@ -117,6 +119,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 +150,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 */ @@ -149,9 +164,9 @@ namespace DNS Module* const creator; 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) + : Timer(ServerInstance->Config->ConfValue("dns")->getDuration("timeout", 5, 1)) , manager(mgr) + , question(addr, qt) , use_cache(usecache) , id(0) , creator(mod) @@ -176,9 +191,9 @@ namespace DNS /** Used to time out the query, calls OnError and asks the TimerManager * to delete this request */ - bool Tick(time_t now) + bool Tick(time_t now) CXX11_OVERRIDE { - Query rr(*this); + Query rr(this->question); rr.error = ERROR_TIMEDOUT; this->OnError(&rr); delete this;