From: Remi Gacogne Date: Fri, 22 Sep 2023 08:22:12 +0000 (+0200) Subject: dnsdist: Move internal DoQ structures to doq.cc X-Git-Tag: rec-5.0.0-alpha2~6^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=805b22fedb2b7419665e24be192439181e65795a;p=thirdparty%2Fpdns.git dnsdist: Move internal DoQ structures to doq.cc --- diff --git a/pdns/dnsdistdist/doq.cc b/pdns/dnsdistdist/doq.cc index 2df6b6a404..0617ffcd86 100644 --- a/pdns/dnsdistdist/doq.cc +++ b/pdns/dnsdistdist/doq.cc @@ -36,6 +36,32 @@ static std::string s_quicRetryTokenKey = newKey(false); +#ifdef HAVE_DNS_OVER_QUIC + +#include + +using QuicheConnection = std::unique_ptr; +using QuicheConfig = std::unique_ptr; + +class Connection +{ +public: + Connection(const ComboAddress& peer, std::unique_ptr&& conn) : + d_peer(peer), d_conn(std::move(conn)) + { + } + Connection(const Connection&) = delete; + Connection(Connection&&) = default; + Connection& operator=(const Connection&) = delete; + Connection& operator=(Connection&&) = default; + ~Connection() = default; + + ComboAddress d_peer; + QuicheConnection d_conn; +}; + +#endif + static void sendBackDOQUnit(DOQUnitUniquePtr&& du, const char* description); struct DOQServerConfig { @@ -94,7 +120,7 @@ public: } auto du = std::move(response.d_idstate.doqu); - if (du->responseSender == nullptr) { + if (du->dsc == nullptr) { return; } @@ -407,11 +433,11 @@ static std::optional> getConnection(const Pac static void sendBackDOQUnit(DOQUnitUniquePtr&& du, const char* description) { - if (du->responseSender == nullptr) { + if (du->dsc == nullptr) { return; } try { - if (!du->responseSender->send(std::move(du))) { + if (!du->dsc->d_responseSender.send(std::move(du))) { vinfolog("Unable to pass a %s to the DoQ worker thread because the pipe is full", description); } } catch (const std::exception& e) { @@ -640,7 +666,6 @@ static void doq_dispatch_query(DOQServerConfig& dsc, PacketBuffer&& query, const du->ids.protocol = dnsdist::Protocol::DoQ; du->serverConnID = serverConnID; du->streamID = streamID; - du->responseSender = &dsc.d_responseSender; processDOQQuery(std::move(du)); } diff --git a/pdns/dnsdistdist/doq.hh b/pdns/dnsdistdist/doq.hh index a45110411a..112fa09751 100644 --- a/pdns/dnsdistdist/doq.hh +++ b/pdns/dnsdistdist/doq.hh @@ -29,32 +29,6 @@ #include "stat_t.hh" #include "dnsdist-idstate.hh" -#ifdef HAVE_DNS_OVER_QUIC - -#include - -using QuicheConnection = std::unique_ptr; -using QuicheConfig = std::unique_ptr; - -class Connection -{ -public: - Connection(const ComboAddress& peer, std::unique_ptr&& conn) : - d_peer(peer), d_conn(std::move(conn)) - { - } - Connection(const Connection&) = delete; - Connection(Connection&&) = default; - Connection& operator=(const Connection&) = delete; - Connection& operator=(Connection&&) = default; - ~Connection() = default; - - ComboAddress d_peer; - QuicheConnection d_conn; -}; - -#endif - struct DOQServerConfig; struct DownstreamState; @@ -94,16 +68,14 @@ struct DOQUnit InternalQueryState ids; PacketBuffer query; PacketBuffer response; + PacketBuffer serverConnID; std::shared_ptr downstream{nullptr}; DOQServerConfig* dsc{nullptr}; - pdns::channel::Sender* responseSender{nullptr}; - size_t proxyProtocolPayloadSize{0}; uint64_t streamID{0}; - PacketBuffer serverConnID; + size_t proxyProtocolPayloadSize{0}; /* whether the query was re-sent to the backend over TCP after receiving a truncated answer over UDP */ bool tcp{false}; - bool truncated{false}; }; using DOQUnitUniquePtr = std::unique_ptr;