From: Remi Gacogne Date: Tue, 8 Apr 2025 08:05:52 +0000 (+0200) Subject: dnsdist: Fix compilation with DoH3 enabled and DoH disabled X-Git-Tag: dnsdist-2.0.0-alpha2~90^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b20f48b75f0707dd4939cdc3365a9d0537072bee;p=thirdparty%2Fpdns.git dnsdist: Fix compilation with DoH3 enabled and DoH disabled While unusual, this is a completely valid setup. --- diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index 7f0e633d94..84be6b09c2 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -284,6 +284,7 @@ static bool handleTLSConfiguration(const dnsdist::rust::settings::BindConfigurat state.doh3Frontend = std::move(frontend); } #endif /* HAVE_DNS_OVER_HTTP3 */ +#if defined(HAVE_DNS_OVER_HTTPS) else if (protocol == "doh") { auto frontend = std::make_shared(); frontend->d_tlsContext.d_provider = std::string(bind.tls.provider); @@ -355,6 +356,7 @@ static bool handleTLSConfiguration(const dnsdist::rust::settings::BindConfigurat frontend->d_tlsContext.d_tlsConfig = std::move(tlsConfig); state.dohFrontend = std::move(frontend); } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ else if (protocol != "do53") { errlog("Bind %s is configured to use an unknown protocol ('%s')", bind.listen_address, protocol); return false; diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc index 5c6530dca0..c5f204e853 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc @@ -512,69 +512,92 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx) #if defined(HAVE_DNS_OVER_HTTPS) || defined(HAVE_DNS_OVER_HTTP3) luaCtx.registerFunction("getHTTPPath", [](const DNSQuestion& dnsQuestion) { +#if defined(HAVE_DNS_OVER_HTTPS) if (dnsQuestion.ids.du) { return dnsQuestion.ids.du->getHTTPPath(); } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ +#if defined(HAVE_DNS_OVER_HTTP3) if (dnsQuestion.ids.doh3u) { return dnsQuestion.ids.doh3u->getHTTPPath(); } +#endif /* defined(HAVE_DNS_OVER_HTTP3) */ return std::string(); }); luaCtx.registerFunction("getHTTPQueryString", [](const DNSQuestion& dnsQuestion) { +#if defined(HAVE_DNS_OVER_HTTPS) if (dnsQuestion.ids.du) { return dnsQuestion.ids.du->getHTTPQueryString(); } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ +#if defined(HAVE_DNS_OVER_HTTP3) if (dnsQuestion.ids.doh3u) { return dnsQuestion.ids.doh3u->getHTTPQueryString(); } +#endif /* defined(HAVE_DNS_OVER_HTTP3) */ return std::string(); }); luaCtx.registerFunction("getHTTPHost", [](const DNSQuestion& dnsQuestion) { +#if defined(HAVE_DNS_OVER_HTTPS) if (dnsQuestion.ids.du) { return dnsQuestion.ids.du->getHTTPHost(); } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ +#if defined(HAVE_DNS_OVER_HTTP3) if (dnsQuestion.ids.doh3u) { return dnsQuestion.ids.doh3u->getHTTPHost(); } +#endif /* defined(HAVE_DNS_OVER_HTTP3) */ return std::string(); }); luaCtx.registerFunction("getHTTPScheme", [](const DNSQuestion& dnsQuestion) { +#if defined(HAVE_DNS_OVER_HTTPS) if (dnsQuestion.ids.du) { return dnsQuestion.ids.du->getHTTPScheme(); } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ +#if defined(HAVE_DNS_OVER_HTTP3) if (dnsQuestion.ids.doh3u) { return dnsQuestion.ids.doh3u->getHTTPScheme(); } +#endif /* defined(HAVE_DNS_OVER_HTTP3) */ return std::string(); }); luaCtx.registerFunction (DNSQuestion::*)(void) const>("getHTTPHeaders", [](const DNSQuestion& dnsQuestion) { +#if defined(HAVE_DNS_OVER_HTTPS) if (dnsQuestion.ids.du) { // coverity[auto_causes_copy] return dnsQuestion.ids.du->getHTTPHeaders(); } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ +#if defined(HAVE_DNS_OVER_HTTP3) if (dnsQuestion.ids.doh3u) { // coverity[auto_causes_copy] return dnsQuestion.ids.doh3u->getHTTPHeaders(); } +#endif /* defined(HAVE_DNS_OVER_HTTP3) */ return LuaAssociativeTable(); }); - luaCtx.registerFunction contentType)>("setHTTPResponse", [](DNSQuestion& dnsQuestion, uint64_t statusCode, const std::string& body, const boost::optional& contentType) { + luaCtx.registerFunction contentType)>("setHTTPResponse", [](DNSQuestion& dnsQuestion, uint64_t statusCode, const std::string& body, [[maybe_unused]] const boost::optional& contentType) { if (dnsQuestion.ids.du == nullptr && dnsQuestion.ids.doh3u == nullptr) { return; } checkParameterBound("DNSQuestion::setHTTPResponse", statusCode, std::numeric_limits::max()); PacketBuffer vect(body.begin(), body.end()); +#if defined(HAVE_DNS_OVER_HTTPS) if (dnsQuestion.ids.du) { dnsQuestion.ids.du->setHTTPResponse(statusCode, std::move(vect), contentType ? *contentType : ""); + return; } - else { - dnsQuestion.ids.doh3u->setHTTPResponse(statusCode, std::move(vect), contentType ? *contentType : ""); - } +#endif /* defined(HAVE_DNS_OVER_HTTPS) */ +#if defined(HAVE_DNS_OVER_HTTP3) + dnsQuestion.ids.doh3u->setHTTPResponse(statusCode, std::move(vect), contentType ? *contentType : ""); +#endif /* defined(HAVE_DNS_OVER_HTTP3) */ }); #endif /* HAVE_DNS_OVER_HTTPS HAVE_DNS_OVER_HTTP3 */