]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Convert proxy protocol to structured logging
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 23 Dec 2025 15:31:10 +0000 (16:31 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 19 Jan 2026 10:00:54 +0000 (11:00 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-proxy-protocol.cc

index ec927341bdf2736137841e49325e784ecccd1a20..c2ae7c0564ce0205c738dec2bf3093ef6622f302 100644 (file)
@@ -86,11 +86,13 @@ bool handleProxyProtocol(const ComboAddress& remote, bool isTCP, const NetmaskGr
   ssize_t used = parseProxyHeader(query, proxyProto, realRemote, realDestination, tcp, values);
   if (used <= 0) {
     ++dnsdist::metrics::g_stats.proxyProtocolInvalid;
-    vinfolog("Ignoring invalid proxy protocol (%d, %d) query over %s from %s", query.size(), used, (isTCP ? "TCP" : "UDP"), remote.toStringWithPort());
+    VERBOSESLOG(infolog("Ignoring invalid proxy protocol (%d, %d) query over %s from %s", query.size(), used, (isTCP ? "TCP" : "UDP"), remote.toStringWithPort()),
+                dnsdist::logging::getTopLogger()->info(Logr::Info, "Ignoring invalid proxy protocol header", "dns.query.size", Logging::Loggable(query.size()), "proxy_protocol_parsed", Logging::Loggable(used), "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote)));
     return false;
   }
   if (static_cast<size_t>(used) > dnsdist::configuration::getCurrentRuntimeConfiguration().d_proxyProtocolMaximumSize) {
-    vinfolog("Proxy protocol header in %s packet from %s is larger than proxy-protocol-maximum-size (%d), dropping", (isTCP ? "TCP" : "UDP"), remote.toStringWithPort(), used);
+    VERBOSESLOG(infolog("Proxy protocol header in %s packet from %s is larger than proxy-protocol-maximum-size (%d), dropping", (isTCP ? "TCP" : "UDP"), remote.toStringWithPort(), used),
+                dnsdist::logging::getTopLogger()->info(Logr::Info, "Proxy protocol header is larger than proxy-protocol-maximum-size, dropping", "proxy_protocol_parsed", Logging::Loggable(used), "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote)));
     ++dnsdist::metrics::g_stats.proxyProtocolInvalid;
     return false;
   }
@@ -105,7 +107,8 @@ bool handleProxyProtocol(const ComboAddress& remote, bool isTCP, const NetmaskGr
 
   if (proxyProto && dnsdist::configuration::getCurrentRuntimeConfiguration().d_applyACLToProxiedClients) {
     if (!acl.match(realRemote)) {
-      vinfolog("Query from %s dropped because of ACL", realRemote.toStringWithPort());
+      VERBOSESLOG(infolog("Query from %s dropped because of ACL", realRemote.toStringWithPort()),
+                  dnsdist::logging::getTopLogger()->info(Logr::Info, "Query with proxy protocol header dropped because of ACL", "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote), "client.address", Logging::Loggable(realRemote)));
       ++dnsdist::metrics::g_stats.aclDrops;
       return false;
     }