]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix a crash with DoH backends in verbose health-check mode 17288/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 4 May 2026 12:53:10 +0000 (14:53 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 4 May 2026 12:53:51 +0000 (14:53 +0200)
Reported by Mehtab Zafar, many thanks!

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-healthchecks.cc

index 59c78e4057b1174429bf5db5ba7e8929fb94a797..59fa35ea0b327ae5ee8fed3b72e5df55003c2666 100644 (file)
@@ -71,10 +71,25 @@ static void updateLatencyMetrics(DownstreamState& downstream, double elapsedUs /
   }
 }
 
+static std::string getHealthCheckProtocol(const std::shared_ptr<const HealthCheckData>& data)
+{
+  const auto& downstream = data->d_ds;
+  if (!downstream->doHealthcheckOverTCP()) {
+    return "udp";
+  }
+  if (downstream->isDoH()) {
+    return "DoH";
+  }
+  if (data->d_tcpHandler && data->d_tcpHandler->isTLS()) {
+    return "DoT";
+  }
+  return "tcp";
+}
+
 static std::shared_ptr<Logr::Logger> getLoggerFromData(const std::shared_ptr<const HealthCheckData>& data)
 {
   const auto& downstream = data->d_ds;
-  return dnsdist::logging::getTopLogger("backend-health-check")->withValues("health_check.proto", Logging::Loggable(downstream->doHealthcheckOverTCP() ? (data->d_tcpHandler->isTLS() ? "DoT" : "tcp") : "udp"), "backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote), "dns.query.id", Logging::Loggable(data->d_queryID), "dns.query.name", Logging::Loggable(data->d_checkName), "dns.query.type", Logging::Loggable(data->d_checkType), "dns.query.class", Logging::Loggable(data->d_checkClass));
+  return dnsdist::logging::getTopLogger("backend-health-check")->withValues("health_check.proto", Logging::Loggable(getHealthCheckProtocol(data)), "backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote), "dns.query.id", Logging::Loggable(data->d_queryID), "dns.query.name", Logging::Loggable(data->d_checkName), "dns.query.type", Logging::Loggable(data->d_checkType), "dns.query.class", Logging::Loggable(data->d_checkClass));
 }
 
 static bool validateHealthCheckResponseWithCallback(const std::shared_ptr<const HealthCheckData>& data)