]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Revert "Use new DNSResourceRecord constructor in resolver."
authorKees Monshouwer <mind04@monshouwer.org>
Fri, 12 Jul 2013 22:04:11 +0000 (00:04 +0200)
committermind04 <mind04@monshouwer.org>
Thu, 18 Jul 2013 13:07:44 +0000 (15:07 +0200)
It broke on the _root._tcp.dc.test.com SVR record

This reverts commit 53840390bb31e6176e2955a26bd494099d19ac1e.

pdns/resolver.cc

index e4b10eaace2b140409a10e2cd63b120736c98e83..13043c1ff8348b098b2f12ec917ba6c8764adee0 100644 (file)
@@ -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<DNSResourceRecord> 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<string> 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<pair<string::size_type, string::size_type> > 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);
   }