From: Charles-Henri Bruyand Date: Thu, 21 Sep 2023 09:32:18 +0000 (+0200) Subject: doq: use dnsdist::getRandomValue and fix a few compilation warnings X-Git-Tag: rec-5.0.0-alpha2~6^2~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a1a819fdbdaee1268a94f17b392bede82e58c259;p=thirdparty%2Fpdns.git doq: use dnsdist::getRandomValue and fix a few compilation warnings --- diff --git a/pdns/dnsdistdist/doq.cc b/pdns/dnsdistdist/doq.cc index 8d704a17dc..80c1c39359 100644 --- a/pdns/dnsdistdist/doq.cc +++ b/pdns/dnsdistdist/doq.cc @@ -23,6 +23,7 @@ #include "doq.hh" #include "dnsdist-tcp.hh" +#include "dnsdist-random.hh" #include "dolog.hh" #include "iputils.hh" #include "misc.hh" @@ -33,9 +34,8 @@ #include "dnsdist-proxy-protocol.hh" static void sendBackDOQUnit(DOQUnitUniquePtr&& du, const char* description); -class DOQServerConfig +struct DOQServerConfig { -public: DOQServerConfig(std::unique_ptr&& config_) : config(std::move(config_)) { @@ -264,16 +264,13 @@ void DOQFrontend::setup() static std::optional getCID() { - // FIXME replace it - int rng = open("/dev/urandom", O_RDONLY); - if (rng < 0) { - return std::nullopt; - } PacketBuffer buffer; + size_t idx = 0; + buffer.resize(LOCAL_CONN_ID_LEN); - auto got = read(rng, buffer.data(), LOCAL_CONN_ID_LEN); - if (got < 0) { - return std::nullopt; + while (idx < LOCAL_CONN_ID_LEN) { + buffer.at(idx) = dnsdist::getRandomValue(std::numeric_limits::max()); + ++idx; } return buffer; @@ -623,8 +620,6 @@ void doqThread(ClientState* cs) size_t scid_len = scid.size(); std::array dcid; size_t dcid_len = dcid.size(); - std::array odcid; - size_t odcid_len = odcid.size(); std::array token; size_t token_len = token.size();