From ef03cc093de9cb51089ccad1d2925bc754f3badd Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sun, 25 Oct 2015 17:27:21 +0100 Subject: [PATCH] move auth-only bit away from resolver.cc to communicator.hh where it belongs --- pdns/communicator.hh | 58 ++++++++++++++++++++++++++++++++++++++++++ pdns/resolver.cc | 7 +++--- pdns/resolver.hh | 60 ++------------------------------------------ 3 files changed, 63 insertions(+), 62 deletions(-) diff --git a/pdns/communicator.hh b/pdns/communicator.hh index 7b7df8307..99e3b125a 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -210,4 +210,62 @@ private: bool d_preventSelfNotification; }; +// class that one day might be more than a function to help you get IP addresses for a nameserver +class FindNS +{ +public: + vector lookup(const DNSName &name, DNSBackend *b) + { + vector addresses; + + this->resolve_name(&addresses, name); + + b->lookup(QType(QType::ANY),name); + DNSResourceRecord rr; + while(b->get(rr)) + if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA) + addresses.push_back(rr.content); // SOL if you have a CNAME for an NS + + return addresses; + } + + vector lookup(const DNSName &name, UeberBackend *b) + { + vector addresses; + + this->resolve_name(&addresses, name); + + b->lookup(QType(QType::ANY),name); + DNSResourceRecord rr; + while(b->get(rr)) + if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA) + addresses.push_back(rr.content); // SOL if you have a CNAME for an NS + + return addresses; + } + +private: + void resolve_name(vector* addresses, const DNSName& name) + { + struct addrinfo* res; + struct addrinfo hints; + memset(&hints, 0, sizeof(hints)); + + for(int n = 0; n < 2; ++n) { + hints.ai_family = n ? AF_INET : AF_INET6; + ComboAddress remote; + remote.sin4.sin_family = AF_INET6; + if(!getaddrinfo(name.toString().c_str(), 0, &hints, &res)) { + struct addrinfo* address = res; + do { + memcpy(&remote, address->ai_addr, address->ai_addrlen); + addresses->push_back(remote.toString()); + } while((address = address->ai_next)); + freeaddrinfo(res); + } + } + } +}; + + #endif diff --git a/pdns/resolver.cc b/pdns/resolver.cc index 99d0b17fe..2cc07b0a7 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -22,7 +22,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "packetcache.hh" #include "utility.hh" #include "resolver.hh" #include @@ -39,9 +38,8 @@ #include #include "dns.hh" #include "qtype.hh" -#include "tcpreceiver.hh" + #include "pdnsexception.hh" -#include "statbag.hh" #include "arguments.hh" #include "base64.hh" #include "dnswriter.hh" @@ -49,7 +47,8 @@ #include #include "dns_random.hh" - +#include +#include "gss_context.hh" #include "namespaces.hh" int makeQuerySocket(const ComboAddress& local, bool udpOrTCP) diff --git a/pdns/resolver.hh b/pdns/resolver.hh index fd416f05d..1a234c682 100644 --- a/pdns/resolver.hh +++ b/pdns/resolver.hh @@ -39,8 +39,8 @@ #include "pdnsexception.hh" #include "dns.hh" #include "namespaces.hh" -#include "dnsbackend.hh" -#include "ueberbackend.hh" +#include "dnsrecords.hh" +#include "dnssecinfra.hh" class ResolverException : public PDNSException { @@ -112,61 +112,5 @@ class AXFRRetriever : public boost::noncopyable TSIGRecordContent d_trc; }; -// class that one day might be more than a function to help you get IP addresses for a nameserver -class FindNS -{ -public: - vector lookup(const DNSName &name, DNSBackend *b) - { - vector addresses; - - this->resolve_name(&addresses, name); - - b->lookup(QType(QType::ANY),name); - DNSResourceRecord rr; - while(b->get(rr)) - if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA) - addresses.push_back(rr.content); // SOL if you have a CNAME for an NS - - return addresses; - } - - vector lookup(const DNSName &name, UeberBackend *b) - { - vector addresses; - - this->resolve_name(&addresses, name); - - b->lookup(QType(QType::ANY),name); - DNSResourceRecord rr; - while(b->get(rr)) - if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA) - addresses.push_back(rr.content); // SOL if you have a CNAME for an NS - - return addresses; - } - -private: - void resolve_name(vector* addresses, const DNSName& name) - { - struct addrinfo* res; - struct addrinfo hints; - memset(&hints, 0, sizeof(hints)); - - for(int n = 0; n < 2; ++n) { - hints.ai_family = n ? AF_INET : AF_INET6; - ComboAddress remote; - remote.sin4.sin_family = AF_INET6; - if(!getaddrinfo(name.toString().c_str(), 0, &hints, &res)) { - struct addrinfo* address = res; - do { - memcpy(&remote, address->ai_addr, address->ai_addrlen); - addresses->push_back(remote.toString()); - } while((address = address->ai_next)); - freeaddrinfo(res); - } - } - } -}; #endif /* PDNS_RESOLVER_HH */ -- 2.40.0