From a867410a2183e64d6abe212c5abcac7cf8a95b6b Mon Sep 17 00:00:00 2001 From: Sten Spans Date: Wed, 16 Nov 2022 22:46:21 +0100 Subject: [PATCH] Allow multiple records with same name for etc/hosts processing This seems to do something right at least --- pdns/reczones-helpers.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pdns/reczones-helpers.cc b/pdns/reczones-helpers.cc index 8f613ac92f..daee88e6ff 100644 --- a/pdns/reczones-helpers.cc +++ b/pdns/reczones-helpers.cc @@ -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, -- 2.47.2