]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
getFakeAAAARecords: strip AUTHORITY SOA on A in ANSWER
authorPieter Lexis <pieter.lexis@powerdns.com>
Fri, 11 Jan 2019 14:00:16 +0000 (15:00 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 11 Jan 2019 14:05:38 +0000 (15:05 +0100)
pdns/lua-recursor4.cc

index ddf7722203d54b6c84ad9de88b36b82168bdb87b..a914109cf644a49610eeb37e4eb7febeb3a51da4 100644 (file)
@@ -86,6 +86,7 @@ static int getFakeAAAARecords(const DNSName& qname, const std::string& prefix, v
         }),
       ret.end());
 
+  bool seenA = false;
   for(DNSRecord& rr :  ret)
   {
     if(rr.d_type == QType::A && rr.d_place==DNSResourceRecord::ANSWER) {
@@ -98,8 +99,21 @@ static int getFakeAAAARecords(const DNSName& qname, const std::string& prefix, v
         rr.d_content = std::make_shared<AAAARecordContent>(prefixAddress);
         rr.d_type = QType::AAAA;
       }
+      seenA = true;
     }
   }
+
+  if (seenA) {
+    // We've seen an A in the ANSWER section, so there is no need to keep any
+    // SOA in the AUTHORITY section as this is not a NODATA response.
+    ret.erase(std::remove_if(
+          ret.begin(),
+          ret.end(),
+          [](DNSRecord& rr) {
+            return (rr.d_type == QType::SOA && rr.d_place==DNSResourceRecord::AUTHORITY);
+          }),
+        ret.end());
+  }
   return rcode;
 }