From d0f519b5179fb0875a885f03dbad6834464ecfac Mon Sep 17 00:00:00 2001 From: phonedph1 Date: Tue, 10 Sep 2024 19:51:03 -0600 Subject: [PATCH] Dump more packet cache info: ECS subnet, DO, raw query flags, and base64 encoded response --- pdns/dnsdistdist/dnsdist-cache.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pdns/dnsdistdist/dnsdist-cache.cc b/pdns/dnsdistdist/dnsdist-cache.cc index d6323d8b32..5ce24c28d4 100644 --- a/pdns/dnsdistdist/dnsdist-cache.cc +++ b/pdns/dnsdistdist/dnsdist-cache.cc @@ -28,6 +28,7 @@ #include "dnsdist-ecs.hh" #include "ednssubnet.hh" #include "packetcache.hh" +#include "base64.hh" // NOLINTNEXTLINE(bugprone-easily-swappable-parameters): too cumbersome to change at this point DNSDistPacketCache::DNSDistPacketCache(size_t maxEntries, uint32_t maxTTL, uint32_t minTTL, uint32_t tempFailureTTL, uint32_t maxNegativeTTL, uint32_t staleTTL, bool dontAge, uint32_t shards, bool deferrableInsertLock, bool parseECS) : @@ -507,7 +508,8 @@ uint64_t DNSDistPacketCache::dump(int fileDesc) rcode = dnsHeader.rcode; } - fprintf(filePtr.get(), "%s %" PRId64 " %s ; rcode %" PRIu8 ", key %" PRIu32 ", length %" PRIu16 ", received over UDP %d, added %" PRId64 "\n", value.qname.toString().c_str(), static_cast(value.validity - now), QType(value.qtype).toString().c_str(), rcode, entry.first, value.len, value.receivedOverUDP ? 1 : 0, static_cast(value.added)); + std::string rawResponse = Base64Encode(value.value); + fprintf(filePtr.get(), "%s %" PRId64 " %s %s ; ecs %s, rcode %" PRIu8 ", key %" PRIu32 ", length %" PRIu16 ", received over UDP %d, added %" PRId64 ", dnssecOK %d, raw query flags %" PRIu16 ", base64response %s\n", value.qname.toString().c_str(), static_cast(value.validity - now), QClass(value.qclass).toString().c_str(), QType(value.qtype).toString().c_str(), value.subnet ? value.subnet.get().toString().c_str() : "empty", rcode, entry.first, value.len, value.receivedOverUDP ? 1 : 0, static_cast(value.added), value.dnssecOK ? 1 : 0, value.queryFlags, rawResponse.c_str()); } catch (...) { fprintf(filePtr.get(), "; error printing '%s'\n", value.qname.empty() ? "EMPTY" : value.qname.toString().c_str()); -- 2.47.2