From: Kees Monshouwer Date: Fri, 12 Jul 2013 22:04:11 +0000 (+0200) Subject: Revert "Use new DNSResourceRecord constructor in resolver." X-Git-Tag: rec-3.6.0-rc1~556^2~3^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1370dfe830f3bfbc45205075dfc5d39bd3c2293e;p=thirdparty%2Fpdns.git Revert "Use new DNSResourceRecord constructor in resolver." It broke on the _root._tcp.dc.test.com SVR record This reverts commit 53840390bb31e6176e2955a26bd494099d19ac1e. --- diff --git a/pdns/resolver.cc b/pdns/resolver.cc index e4b10eaace..13043c1ff8 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -155,8 +155,40 @@ static int parseResult(MOADNSParser& mdp, const std::string& origQname, uint16_t throw ResolverException(string("resolver: received an answer to another question (")+mdp.d_qname+"!="+ origQname+".)"); } - for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { - DNSResourceRecord rr(i->first); + vector ret; + DNSResourceRecord rr; + for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { + rr.qname = i->first.d_label; + if(!rr.qname.empty()) + boost::erase_tail(rr.qname, 1); // strip . + rr.qtype = i->first.d_type; + rr.ttl = i->first.d_ttl; + rr.content = i->first.d_content->getZoneRepresentation(); + rr.priority = 0; + + uint16_t qtype=rr.qtype.getCode(); + + if(!rr.content.empty() && (qtype==QType::MX || qtype==QType::NS || qtype==QType::CNAME)) + boost::erase_tail(rr.content, 1); + + if(rr.qtype.getCode() == QType::MX) { + vector parts; + stringtok(parts, rr.content); + rr.priority = atoi(parts[0].c_str()); + if(parts.size() > 1) + rr.content=parts[1]; + else + rr.content="."; + } else if(rr.qtype.getCode() == QType::SRV) { + rr.priority = atoi(rr.content.c_str()); + vector > fields; + vstringtok(fields, rr.content, " "); + if(fields.size()==4) { + if(fields[3].second - fields[3].first > 1) // strip dot, unless root + fields[3].second--; + rr.content=string(rr.content.c_str() + fields[1].first, fields[3].second - fields[1].first); + } + } result->push_back(rr); }