From 619b626a1508e2b4b0e4d1b7b05492da5946fc1c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 1 Jul 2020 11:37:36 +0200 Subject: [PATCH] rec: Dump the authority records of a negative cache entry as well --- pdns/recursordist/negcache.cc | 6 ++++++ pdns/recursordist/test-negcache_cc.cc | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index 0f3dc9eabb..ec8db1c30c 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -203,6 +203,12 @@ uint64_t NegCache::dumpToFile(FILE* fp) for (const NegCacheEntry& ne : sidx) { ret++; fprintf(fp, "%s %" PRId64 " IN %s VIA %s ; (%s)\n", ne.d_name.toString().c_str(), static_cast(ne.d_ttd - now.tv_sec), ne.d_qtype.getName().c_str(), ne.d_auth.toString().c_str(), vStates[ne.d_validationState]); + for (const auto& rec : ne.authoritySOA.records) { + fprintf(fp, "%s %" PRId64 " IN %s %s ; (%s)\n", ne.d_name.toString().c_str(), static_cast(ne.d_ttd - now.tv_sec), DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.d_content->getZoneRepresentation().c_str(), vStates[ne.d_validationState]); + } + for (const auto& sig : ne.authoritySOA.signatures) { + fprintf(fp, "%s %" PRId64 " IN RRSIG %s ;\n", ne.d_name.toString().c_str(), static_cast(ne.d_ttd - now.tv_sec), sig.d_content->getZoneRepresentation().c_str()); + } for (const auto& rec : ne.DNSSECRecords.records) { fprintf(fp, "%s %" PRId64 " IN %s %s ; (%s)\n", ne.d_name.toString().c_str(), static_cast(ne.d_ttd - now.tv_sec), DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.d_content->getZoneRepresentation().c_str(), vStates[ne.d_validationState]); } diff --git a/pdns/recursordist/test-negcache_cc.cc b/pdns/recursordist/test-negcache_cc.cc index 0c33e1cb3a..9554e44ff4 100644 --- a/pdns/recursordist/test-negcache_cc.cc +++ b/pdns/recursordist/test-negcache_cc.cc @@ -417,9 +417,13 @@ BOOST_AUTO_TEST_CASE(test_dumpToFile) NegCache cache; vector expected; expected.push_back("www1.powerdns.com. 600 IN TYPE0 VIA powerdns.com. ; (Indeterminate)\n"); + expected.push_back("www1.powerdns.com. 600 IN SOA ns1. hostmaster. 1 2 3 4 5 ; (Indeterminate)\n"); + expected.push_back("www1.powerdns.com. 600 IN RRSIG SOA 5 3 600 20370101000000 20370101000000 24567 dummy. data ;\n"); expected.push_back("www1.powerdns.com. 600 IN NSEC deadbeef. ; (Indeterminate)\n"); expected.push_back("www1.powerdns.com. 600 IN RRSIG NSEC 5 3 600 20370101000000 20370101000000 24567 dummy. data ;\n"); expected.push_back("www2.powerdns.com. 600 IN TYPE0 VIA powerdns.com. ; (Indeterminate)\n"); + expected.push_back("www2.powerdns.com. 600 IN SOA ns1. hostmaster. 1 2 3 4 5 ; (Indeterminate)\n"); + expected.push_back("www2.powerdns.com. 600 IN RRSIG SOA 5 3 600 20370101000000 20370101000000 24567 dummy. data ;\n"); expected.push_back("www2.powerdns.com. 600 IN NSEC deadbeef. ; (Indeterminate)\n"); expected.push_back("www2.powerdns.com. 600 IN RRSIG NSEC 5 3 600 20370101000000 20370101000000 24567 dummy. data ;\n"); -- 2.47.2