From 5aa12996b544df56c2818c55edc0706af0a00c29 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 24 Oct 2015 09:53:14 +0200 Subject: [PATCH] make it possible to consume AXFR as DNSRecords too --- pdns/resolver.cc | 13 +++++++++++-- pdns/resolver.hh | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pdns/resolver.cc b/pdns/resolver.cc index df8ea6ba6..99d0b17fe 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -438,7 +438,7 @@ AXFRRetriever::~AXFRRetriever() -int AXFRRetriever::getChunk(Resolver::res_t &res) // Implementation is making sure RFC2845 4.4 is followed. +int AXFRRetriever::getChunk(Resolver::res_t &res, vector* records) // Implementation is making sure RFC2845 4.4 is followed. { if(d_soacount > 1) return false; @@ -451,7 +451,16 @@ int AXFRRetriever::getChunk(Resolver::res_t &res) // Implementation is making su timeoutReadn(len); MOADNSParser mdp(d_buf.get(), len); - int err = parseResult(mdp, DNSName(), 0, 0, &res); + int err; + if(!records) + err=parseResult(mdp, DNSName(), 0, 0, &res); + else { + records->clear(); + for(const auto& r: mdp.d_answers) + records->push_back(r.first); + err = mdp.d_header.rcode; + } + if(err) throw ResolverException("AXFR chunk error: " + RCode::to_s(err)); diff --git a/pdns/resolver.hh b/pdns/resolver.hh index d54faa823..fd416f05d 100644 --- a/pdns/resolver.hh +++ b/pdns/resolver.hh @@ -90,7 +90,7 @@ class AXFRRetriever : public boost::noncopyable const string& tsigsecret=string(), const ComboAddress* laddr = NULL); ~AXFRRetriever(); - int getChunk(Resolver::res_t &res); + int getChunk(Resolver::res_t &res, vector* records=0); private: void connect(); -- 2.40.0