]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix compilation with DoH3 enabled and DoH disabled 15407/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 8 Apr 2025 08:05:52 +0000 (10:05 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 8 Apr 2025 08:05:52 +0000 (10:05 +0200)
While unusual, this is a completely valid setup.

pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc

index 7f0e633d9420872e4d64291b26b39f28eaeca6bd..84be6b09c2a855ff922b50a9f27d34aecb277abf 100644 (file)
@@ -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<DOHFrontend>();
     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;
index 5c6530dca0a809c90689254614c0a67738eb03fc..c5f204e8534fc8a59bbd00a31a1976bb3e76e57f 100644 (file)
@@ -512,69 +512,92 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx)
 
 #if defined(HAVE_DNS_OVER_HTTPS) || defined(HAVE_DNS_OVER_HTTP3)
   luaCtx.registerFunction<std::string (DNSQuestion::*)(void) const>("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<std::string (DNSQuestion::*)(void) const>("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<std::string (DNSQuestion::*)(void) const>("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<std::string (DNSQuestion::*)(void) const>("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<LuaAssociativeTable<std::string> (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<std::string>();
   });
 
-  luaCtx.registerFunction<void (DNSQuestion::*)(uint64_t statusCode, const std::string& body, const boost::optional<std::string> contentType)>("setHTTPResponse", [](DNSQuestion& dnsQuestion, uint64_t statusCode, const std::string& body, const boost::optional<std::string>& contentType) {
+  luaCtx.registerFunction<void (DNSQuestion::*)(uint64_t statusCode, const std::string& body, const boost::optional<std::string> contentType)>("setHTTPResponse", [](DNSQuestion& dnsQuestion, uint64_t statusCode, const std::string& body, [[maybe_unused]] const boost::optional<std::string>& contentType) {
     if (dnsQuestion.ids.du == nullptr && dnsQuestion.ids.doh3u == nullptr) {
       return;
     }
     checkParameterBound("DNSQuestion::setHTTPResponse", statusCode, std::numeric_limits<uint16_t>::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 */