From: Remi Gacogne Date: Mon, 4 May 2026 12:53:10 +0000 (+0200) Subject: dnsdist: Fix a crash with DoH backends in verbose health-check mode X-Git-Tag: auth-5.1.0~82^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f8a06d5bc3da3460bfd55463011f56b2175ebda;p=thirdparty%2Fpdns.git dnsdist: Fix a crash with DoH backends in verbose health-check mode Reported by Mehtab Zafar, many thanks! Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-healthchecks.cc b/pdns/dnsdistdist/dnsdist-healthchecks.cc index 59c78e4057..59fa35ea0b 100644 --- a/pdns/dnsdistdist/dnsdist-healthchecks.cc +++ b/pdns/dnsdistdist/dnsdist-healthchecks.cc @@ -71,10 +71,25 @@ static void updateLatencyMetrics(DownstreamState& downstream, double elapsedUs / } } +static std::string getHealthCheckProtocol(const std::shared_ptr& 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 getLoggerFromData(const std::shared_ptr& 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& data)