]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix compilation errors w/o DoQ and DoH3, plus clang-tidy warnings
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 28 Jan 2025 16:07:34 +0000 (17:07 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 28 Jan 2025 16:07:34 +0000 (17:07 +0100)
pdns/dnsdistdist/dnsdist-actions-factory.cc
pdns/dnsdistdist/dnsdist-actions-factory.hh
pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-lua-ffi-interface.h
pdns/dnsdistdist/dnsdist-lua-ffi.cc
pdns/dnsdistdist/dnsdist-lua-web.cc
pdns/dnsdistdist/dnsdist-nghttp2.cc
pdns/dnsdistdist/dnsdist-tcp-downstream.cc
pdns/dnsdistdist/test-dnsdist-connections-cache.cc

index b821f07a0599c7cecaf0cd2dd02692ca6da97f77..a74d8d28b65edd93ab233d559361744852c7683f 100644 (file)
@@ -2355,13 +2355,15 @@ std::shared_ptr<DNSAction> getKeyValueStoreRangeLookupAction(std::shared_ptr<Key
 }
 #endif /* defined(HAVE_LMDB) || defined(HAVE_CDB) */
 
-#ifdef HAVE_DNS_OVER_HTTPS
 std::shared_ptr<DNSAction> getHTTPStatusAction(uint16_t status, PacketBuffer&& body, const std::string& contentType, const dnsdist::ResponseConfig& responseConfig)
 {
+#if defined(HAVE_DNS_OVER_HTTPS)
   return std::shared_ptr<DNSAction>(new HTTPStatusAction(status, std::move(body), contentType, responseConfig));
+#else
+  throw std::runtime_error("Unsupported HTTPStatus action");
+#endif
 }
 
-#endif
 
 std::shared_ptr<DNSResponseAction> getLimitTTLResponseAction(uint32_t min, uint32_t max, std::unordered_set<QType> types)
 {
index 8aa98eee1338efdd9c92b143922744899419f362..7ef95d3810d03982fc5fa0650ce8afd3728f6616 100644 (file)
@@ -68,9 +68,7 @@ std::shared_ptr<DNSResponseAction> getLuaResponseAction(dnsdist::actions::LuaRes
 std::shared_ptr<DNSResponseAction> getLuaFFIResponseAction(dnsdist::actions::LuaResponseActionFFIFunction function);
 
 std::shared_ptr<DNSAction> getContinueAction(std::shared_ptr<DNSAction> action);
-#ifdef HAVE_DNS_OVER_HTTPS
 std::shared_ptr<DNSAction> getHTTPStatusAction(uint16_t status, PacketBuffer&& body, const std::string& contentType, const dnsdist::ResponseConfig& responseConfig);
-#endif
 std::shared_ptr<DNSAction> getNegativeAndSOAAction(bool nxd, const DNSName& zone, uint32_t ttl, const DNSName& mname, const DNSName& rname, const SOAParams& params, bool soaInAuthority, dnsdist::ResponseConfig responseConfig);
 std::shared_ptr<DNSAction> getSetProxyProtocolValuesAction(const std::vector<std::pair<uint8_t, std::string>>& values);
 std::shared_ptr<DNSAction> getRCodeAction(uint8_t rcode, const dnsdist::ResponseConfig& responseConfig);
index 30597d3b5e795c9b3dd950cb0528dee362fc8bfe..7a98f939ba65cd5cf5aea4be50975d09397d428e 100644 (file)
@@ -250,6 +250,7 @@ static bool handleTLSConfiguration(const dnsdist::rust::settings::BindConfigurat
     frontend->d_tlsConfig = std::move(tlsConfig);
     state.tlsFrontend = std::move(frontend);
   }
+#if defined(HAVE_DNS_OVER_QUIC)
   else if (protocol == "doq") {
     auto frontend = std::make_shared<DOQFrontend>();
     frontend->d_local = ComboAddress(std::string(bind.listen_address), 853);
@@ -263,6 +264,8 @@ static bool handleTLSConfiguration(const dnsdist::rust::settings::BindConfigurat
     frontend->d_internalPipeBufferSize = bind.quic.internal_pipe_buffer_size;
     state.doqFrontend = std::move(frontend);
   }
+#endif /* HAVE_DNS_OVER_QUIC */
+#if defined(HAVE_DNS_OVER_HTTP3)
   else if (protocol == "doh3") {
     auto frontend = std::make_shared<DOH3Frontend>();
     frontend->d_local = ComboAddress(std::string(bind.listen_address), 443);
@@ -275,6 +278,7 @@ static bool handleTLSConfiguration(const dnsdist::rust::settings::BindConfigurat
     frontend->d_internalPipeBufferSize = bind.quic.internal_pipe_buffer_size;
     state.doh3Frontend = std::move(frontend);
   }
+#endif /* HAVE_DNS_OVER_HTTP3 */
   else if (protocol == "doh") {
     auto frontend = std::make_shared<DOHFrontend>();
     frontend->d_tlsContext.d_provider = std::string(bind.tls.provider);
index 5f491614665136b0a30fff1fa6f1591bdd58fad1..5d6bb216c470e8aa4cc59e6767b7e6fab5d29635 100644 (file)
@@ -117,7 +117,7 @@ void dnsdist_ffi_dnsquestion_set_requestor_id(dnsdist_ffi_dnsquestion_t* dq, con
 void dnsdist_ffi_dnsquestion_set_device_id(dnsdist_ffi_dnsquestion_t* dq, const char* value, size_t valueSize) __attribute__ ((visibility ("default")));
 void dnsdist_ffi_dnsquestion_set_device_name(dnsdist_ffi_dnsquestion_t* dq, const char* value, size_t valueSize) __attribute__ ((visibility ("default")));
 
-void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* dq, uint16_t statusCode, const char* body, size_t bodyLen, const char* contentType) __attribute__ ((visibility ("default")));
+void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* ref, uint16_t statusCode, const char* body, size_t bodyLen, const char* contentType) __attribute__ ((visibility ("default")));
 
 void dnsdist_ffi_dnsquestion_set_extended_dns_error(dnsdist_ffi_dnsquestion_t* dnsQuestion, uint16_t infoCode, const char* extraText, size_t extraTextSize) __attribute__ ((visibility ("default")));
 
index 5c602da4ec1c16dc19dc2454430165da16fb2965..43198f5c66897261fde713395f24cafd3e37d0ef 100644 (file)
@@ -419,48 +419,48 @@ size_t dnsdist_ffi_dnsquestion_get_edns_options(dnsdist_ffi_dnsquestion_t* dq, c
   return totalCount;
 }
 
-size_t dnsdist_ffi_dnsquestion_get_http_headers(dnsdist_ffi_dnsquestion_t* dq, [[maybe_unused]] const dnsdist_ffi_http_header_t** out)
+size_t dnsdist_ffi_dnsquestion_get_http_headers(dnsdist_ffi_dnsquestion_t* ref, [[maybe_unused]] const dnsdist_ffi_http_header_t** out)
 {
 #if defined(HAVE_DNS_OVER_HTTPS) || defined(HAVE_DNS_OVER_HTTP3)
-  const auto processHeaders = [&dq](const std::unordered_map<std::string, std::string>& headers) {
+  const auto processHeaders = [&ref](const std::unordered_map<std::string, std::string>& headers) {
     if (headers.empty()) {
       return;
     }
-    dq->httpHeaders = std::make_unique<std::unordered_map<std::string, std::string>>(headers);
-    if (!dq->httpHeadersVect) {
-      dq->httpHeadersVect = std::make_unique<std::vector<dnsdist_ffi_http_header_t>>();
+    ref->httpHeaders = std::make_unique<std::unordered_map<std::string, std::string>>(headers);
+    if (!ref->httpHeadersVect) {
+      ref->httpHeadersVect = std::make_unique<std::vector<dnsdist_ffi_http_header_t>>();
     }
-    dq->httpHeadersVect->clear();
-    dq->httpHeadersVect->resize(dq->httpHeaders->size());
+    ref->httpHeadersVect->clear();
+    ref->httpHeadersVect->resize(ref->httpHeaders->size());
     size_t pos = 0;
-    for (const auto& header : *dq->httpHeaders) {
-      dq->httpHeadersVect->at(pos).name = header.first.c_str();
-      dq->httpHeadersVect->at(pos).value = header.second.c_str();
+    for (const auto& header : *ref->httpHeaders) {
+      ref->httpHeadersVect->at(pos).name = header.first.c_str();
+      ref->httpHeadersVect->at(pos).value = header.second.c_str();
       ++pos;
     }
   };
 
 #if defined(HAVE_DNS_OVER_HTTPS)
-  if (dq->dq->ids.du) {
-    const auto& headers = dq->dq->ids.du->getHTTPHeaders();
+  if (ref->dq->ids.du) {
+    const auto& headers = ref->dq->ids.du->getHTTPHeaders();
     processHeaders(headers);
   }
 #endif /* HAVE_DNS_OVER_HTTPS */
 #if defined(HAVE_DNS_OVER_HTTP3)
-  if (dq->dq->ids.doh3u) {
-    const auto& headers = dq->dq->ids.doh3u->getHTTPHeaders();
+  if (ref->dq->ids.doh3u) {
+    const auto& headers = ref->dq->ids.doh3u->getHTTPHeaders();
     processHeaders(headers);
   }
 #endif /* HAVE_DNS_OVER_HTTP3 */
 
-  if (!dq->httpHeadersVect) {
+  if (!ref->httpHeadersVect) {
     return 0;
   }
 
-  if (!dq->httpHeadersVect->empty()) {
-    *out = dq->httpHeadersVect->data();
+  if (!ref->httpHeadersVect->empty()) {
+    *out = ref->httpHeadersVect->data();
   }
-  return dq->httpHeadersVect->size();
+  return ref->httpHeadersVect->size();
 #else /* HAVE_DNS_OVER_HTTPS || HAVE_DNS_OVER_HTTP3 */
   return 0;
 #endif /* HAVE_DNS_OVER_HTTPS || HAVE_DNS_OVER_HTTP3 */
@@ -498,25 +498,25 @@ void dnsdist_ffi_dnsquestion_set_result(dnsdist_ffi_dnsquestion_t* dq, const cha
   dq->result = std::string(str, strSize);
 }
 
-void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* dq, [[maybe_unused]] uint16_t statusCode, [[maybe_unused]] const char* body, [[maybe_unused]] size_t bodyLen, [[maybe_unused]] const char* contentType)
+void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* ref, [[maybe_unused]] uint16_t statusCode, [[maybe_unused]] const char* body, [[maybe_unused]] size_t bodyLen, [[maybe_unused]] const char* contentType)
 {
 #if defined(HAVE_DNS_OVER_HTTPS)
-  if (dq->dq->ids.du) {
+  if (ref->dq->ids.du) {
     // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): C API
     PacketBuffer bodyVect(body, body + bodyLen);
-    dq->dq->ids.du->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
-    dnsdist::PacketMangling::editDNSHeaderFromPacket(dq->dq->getMutableData(), [](dnsheader& header) {
+    ref->dq->ids.du->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
+    dnsdist::PacketMangling::editDNSHeaderFromPacket(ref->dq->getMutableData(), [](dnsheader& header) {
       header.qr = true;
       return true;
     });
   }
 #endif
 #if defined(HAVE_DNS_OVER_HTTP3)
-  if (dq->dq->ids.doh3u) {
+  if (ref->dq->ids.doh3u) {
     // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): C API
     PacketBuffer bodyVect(body, body + bodyLen);
-    dq->dq->ids.doh3u->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
-    dnsdist::PacketMangling::editDNSHeaderFromPacket(dq->dq->getMutableData(), [](dnsheader& header) {
+    ref->dq->ids.doh3u->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
+    dnsdist::PacketMangling::editDNSHeaderFromPacket(ref->dq->getMutableData(), [](dnsheader& header) {
       header.qr = true;
       return true;
     });
index a8b169b1195433284895a93d897c000ecfb36659..7dbd51504237e323f73876ad38c6e4e0267558dc 100644 (file)
@@ -41,7 +41,7 @@ void setupLuaWeb([[maybe_unused]] LuaContext& luaCtx)
   luaCtx.registerMember<std::string(YaHTTP::Request::*)>("path", [](const YaHTTP::Request& req) -> std::string { return req.url.path; }, [](YaHTTP::Request& req, const std::string& path) { (void)req; (void) path; });
   luaCtx.registerMember<int(YaHTTP::Request::*)>("version", [](const YaHTTP::Request& req) -> int { return req.version; }, [](YaHTTP::Request& req, int version) { (void)req; (void)version; });
   luaCtx.registerMember<std::string(YaHTTP::Request::*)>("method", [](const YaHTTP::Request& req) -> std::string { return req.method; }, [](YaHTTP::Request& req, const std::string& method) { (void)req; (void) method; });
-  luaCtx.registerMember<std::string(YaHTTP::Request::*)>("body", [](const YaHTTP::Request& req) -> const std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void)req; (void)body; });
+  luaCtx.registerMember<std::string(YaHTTP::Request::*)>("body", [](const YaHTTP::Request& req) -> std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void)req; (void)body; });
   luaCtx.registerMember<LuaAssociativeTable<std::string>(YaHTTP::Request::*)>("getvars", [](const YaHTTP::Request& req) {
     LuaAssociativeTable<std::string> values;
     for (const auto& entry : req.getvars) {
index 03af2b5bba9836dc59c6fb46607e20af70c4682f..ed9ac00820a2c4d523fd950edb7075a31b30ad99 100644 (file)
@@ -1045,7 +1045,7 @@ bool initDoHWorkers()
 #endif /* HAVE_DNS_OVER_HTTPS && HAVE_NGHTTP2 */
 }
 
-bool sendH2Query([[maybe_unused]] const std::shared_ptr<DownstreamState>& ds, [[maybe_unused]] std::unique_ptr<FDMultiplexer>& mplexer, [[maybe_unused]] std::shared_ptr<TCPQuerySender>& sender, [[maybe_unused]] InternalQuery&& query, [[maybe_unused]] bool healthCheck)
+bool sendH2Query([[maybe_unused]] const std::shared_ptr<DownstreamState>& downstream, [[maybe_unused]] std::unique_ptr<FDMultiplexer>& mplexer, [[maybe_unused]] std::shared_ptr<TCPQuerySender>& sender, [[maybe_unused]] InternalQuery&& query, [[maybe_unused]] bool healthCheck)
 {
 #if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2)
   struct timeval now
@@ -1056,12 +1056,12 @@ bool sendH2Query([[maybe_unused]] const std::shared_ptr<DownstreamState>& ds, [[
 
   if (healthCheck) {
     /* always do health-checks over a new connection */
-    auto newConnection = std::make_shared<DoHConnectionToBackend>(ds, mplexer, now, std::move(query.d_proxyProtocolPayload));
+    auto newConnection = std::make_shared<DoHConnectionToBackend>(downstream, mplexer, now, std::move(query.d_proxyProtocolPayload));
     newConnection->setHealthCheck(healthCheck);
     newConnection->queueQuery(sender, std::move(query));
   }
   else {
-    auto connection = t_downstreamDoHConnectionsManager.getConnectionToDownstream(mplexer, ds, now, std::move(query.d_proxyProtocolPayload));
+    auto connection = t_downstreamDoHConnectionsManager.getConnectionToDownstream(mplexer, downstream, now, std::move(query.d_proxyProtocolPayload));
     connection->queueQuery(sender, std::move(query));
   }
 
index d23350b4d1174b3d850f8f94d3e0027cf81a39a4..cd14a08347f91e847620380722023057767ef0b2 100644 (file)
@@ -229,7 +229,7 @@ enum class ConnectionState : uint8_t {
   proxySent
 };
 
-static void prepareQueryForSending(TCPQuery& query, uint16_t id, ConnectionState connectionState)
+static void prepareQueryForSending(TCPQuery& query, uint16_t queryID, ConnectionState connectionState)
 {
   if (connectionState == ConnectionState::needProxy) {
     if (query.d_proxyProtocolPayload.size() > 0 && !query.d_proxyProtocolPayloadAdded) {
@@ -253,7 +253,7 @@ static void prepareQueryForSending(TCPQuery& query, uint16_t id, ConnectionState
     getSerialFromIXFRQuery(query);
   }
 
-  editPayloadID(query.d_buffer, id, query.d_proxyProtocolPayloadAdded ? query.d_idstate.d_proxyProtocolPayloadSize : 0, true);
+  editPayloadID(query.d_buffer, queryID, query.d_proxyProtocolPayloadAdded ? query.d_idstate.d_proxyProtocolPayloadSize : 0, true);
 }
 
 IOState TCPConnectionToBackend::queueNextQuery(std::shared_ptr<TCPConnectionToBackend>& conn)
index 00e879af2d44560110f89e1ba49bc6d86b61b7a5..ef5d6779e077d61202b44f981758aeb20f40efa2 100644 (file)
@@ -71,7 +71,7 @@ public:
   {
   }
 
-  void release(bool removeFromCache)
+  static void release(bool removeFromCache)
   {
     (void)removeFromCache;
   }