diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index e78c986394e5..475e7a1a717b 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -450,7 +450,16 @@ uint64_t MemRecursorCache::doDump(int fd) for(const auto j : i.d_records) { count++; try { - fprintf(fp, "%s %" PRId64 " IN %s %s ; %s\n", i.d_qname.toString().c_str(), static_cast(i.d_ttd - now), DNSRecordContent::NumberToType(i.d_qtype).c_str(), j->getZoneRepresentation().c_str(), i.d_netmask.empty() ? "" : i.d_netmask.toString().c_str()); + fprintf(fp, "%s %" PRId64 " IN %s %s ; (%s) auth=%i %s\n", i.d_qname.toString().c_str(), static_cast(i.d_ttd - now), DNSRecordContent::NumberToType(i.d_qtype).c_str(), j->getZoneRepresentation().c_str(), vStates[i.d_state], i.d_auth, i.d_netmask.empty() ? "" : i.d_netmask.toString().c_str()); + } + catch(...) { + fprintf(fp, "; error printing '%s'\n", i.d_qname.empty() ? "EMPTY" : i.d_qname.toString().c_str()); + } + } + for(const auto &sig : i.d_signatures) { + count++; + try { + fprintf(fp, "%s %" PRId64 " IN RRSIG %s ; %s\n", i.d_qname.toString().c_str(), static_cast(i.d_ttd - now), sig->getZoneRepresentation().c_str(), i.d_netmask.empty() ? "" : i.d_netmask.toString().c_str()); } catch(...) { fprintf(fp, "; error printing '%s'\n", i.d_qname.empty() ? "EMPTY" : i.d_qname.toString().c_str()); diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index 49f4e2448eb6..662341dd9a1e 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -170,6 +170,12 @@ uint64_t NegCache::dumpToFile(FILE* fp) { for(const NegCacheEntry& ne : sidx) { ret++; fprintf(fp, "%s %d IN %s VIA %s\n", ne.d_name.toString().c_str(), (unsigned int) (ne.d_ttd - now), ne.d_qtype.getName().c_str(), ne.d_auth.toString().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), DNSRecordContent::NumberToType(ne.d_qtype.getCode()).c_str(), rec.d_content->getZoneRepresentation().c_str(), vStates[ne.d_validationState]); + } + for (const auto& sig : ne.DNSSECRecords.signatures) { + fprintf(fp, "%s %" PRId64 " IN RRSIG %s ;\n", ne.d_name.toString().c_str(), static_cast(ne.d_ttd - now), sig.d_content->getZoneRepresentation().c_str()); + } } return ret; } diff --git a/pdns/recursordist/test-negcache_cc.cc b/pdns/recursordist/test-negcache_cc.cc index 7340884700ce..bc25c3a5ccce 100644 --- a/pdns/recursordist/test-negcache_cc.cc +++ b/pdns/recursordist/test-negcache_cc.cc @@ -336,7 +336,11 @@ BOOST_AUTO_TEST_CASE(test_dumpToFile) { NegCache cache; vector expected; expected.push_back("www1.powerdns.com. 600 IN TYPE0 VIA powerdns.com.\n"); + expected.push_back("www1.powerdns.com. 600 IN ENT deadbeef. ; (Indeterminate)\n"); + expected.push_back("www1.powerdns.com. 600 IN RRSIG NSEC 5 3 600 21000101000000 21000101000000 24567 dummy. data ;\n"); expected.push_back("www2.powerdns.com. 600 IN TYPE0 VIA powerdns.com.\n"); + expected.push_back("www2.powerdns.com. 600 IN ENT deadbeef. ; (Indeterminate)\n"); + expected.push_back("www2.powerdns.com. 600 IN RRSIG NSEC 5 3 600 21000101000000 21000101000000 24567 dummy. data ;\n"); struct timeval now; Utility::gettimeofday(&now, 0);