]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
doq: use dnsdist::getRandomValue and fix a few compilation warnings
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Thu, 21 Sep 2023 09:32:18 +0000 (11:32 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Oct 2023 11:36:48 +0000 (13:36 +0200)
pdns/dnsdistdist/doq.cc

index 8d704a17dca29dd02908841d8c69613c12f34bbb..80c1c39359e5c9a2bbc24b1a674d168f22a78ed9 100644 (file)
@@ -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<quiche_config, decltype(&quiche_config_free)>&& config_) :
     config(std::move(config_))
   {
@@ -264,16 +264,13 @@ void DOQFrontend::setup()
 
 static std::optional<PacketBuffer> 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<uint8_t>::max());
+    ++idx;
   }
 
   return buffer;
@@ -623,8 +620,6 @@ void doqThread(ClientState* cs)
         size_t scid_len = scid.size();
         std::array<uint8_t, QUICHE_MAX_CONN_ID_LEN> dcid;
         size_t dcid_len = dcid.size();
-        std::array<uint8_t, QUICHE_MAX_CONN_ID_LEN> odcid;
-        size_t odcid_len = odcid.size();
         std::array<uint8_t, TOKEN_LEN> token;
         size_t token_len = token.size();