]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Allow multiple records with same name for etc/hosts processing
authorSten Spans <sten@blinkenlights.nl>
Wed, 16 Nov 2022 21:46:21 +0000 (22:46 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 8 Dec 2022 08:51:28 +0000 (09:51 +0100)
This seems to do something right at least

pdns/reczones-helpers.cc

index 8f613ac92fed76c504429897ad8604e04c419a91..daee88e6ffd82f081a1dee9483e6c2f38e3ae561 100644 (file)
@@ -75,17 +75,30 @@ static void makeNameToIPZone(SyncRes::domainmap_t& newMap,
                              const ComboAddress& address,
                              Logr::log_t log)
 {
+  SyncRes::AuthDomain ad;
   DNSRecord dr;
+
   dr.d_name = hostname;
 
-  SyncRes::AuthDomain ad = makeSOAAndNSNodes(dr, "localhost.");
+  if (newMap.count(hostname) != 0) {
+    ad = newMap[hostname];
+  }
+  else {
+    ad = makeSOAAndNSNodes(dr, "localhost.");
+  }
 
   auto recType = address.isIPv6() ? QType::AAAA : QType::A;
   dr.d_type = recType;
+  dr.d_ttl = 86400;
   dr.d_content = DNSRecordContent::mastermake(recType, 1, address.toStringNoInterface());
   ad.d_records.insert(dr);
 
-  addToDomainMap(newMap, ad, dr.d_name, log);
+  if (newMap.count(hostname) != 0) {
+    newMap[ad.d_name] = ad;
+  }
+  else {
+    addToDomainMap(newMap, ad, dr.d_name, log);
+  }
 }
 
 static void makeIPToNamesZone(SyncRes::domainmap_t& newMap,