]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
In dnsdist, (which is not a dns_random consumer), use sdt::default_random_engine 9016/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 21 Apr 2020 12:36:12 +0000 (14:36 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 22 Apr 2020 07:45:08 +0000 (09:45 +0200)
for shuffle.

pdns/dnsdist-lua-actions.cc
pdns/dnsdist-lua.hh

index c3e1e11360f3e896d20cb0976470807177c405e8..9928fd680c3401f99c3acf8b36bc0e5388a2baae 100644 (file)
@@ -520,6 +520,8 @@ private:
   func_t d_func;
 };
 
+thread_local std::default_random_engine SpoofAction::t_randomEngine;
+
 DNSAction::Action SpoofAction::operator()(DNSQuestion* dq, std::string* ruleresult) const
 {
   uint16_t qtype = dq->qtype;
@@ -553,8 +555,9 @@ DNSAction::Action SpoofAction::operator()(DNSQuestion* dq, std::string* ruleresu
     }
   }
 
-  if(addrs.size() > 1)
-    random_shuffle(addrs.begin(), addrs.end());
+  if (addrs.size() > 1) {
+    shuffle(addrs.begin(), addrs.end(), t_randomEngine);
+  }
 
   unsigned int consumed=0;
   DNSName ignore((char*)dq->dh, dq->len, sizeof(dnsheader), false, 0, 0, &consumed);
index 65bfec3fdc389032185692e53c89ae5783c6fbc9..b25be8840fc628bc4b16f90c96075d18f0fd49ee 100644 (file)
@@ -21,6 +21,8 @@
  */
 #pragma once
 
+#include <random>
+
 struct ResponseConfig
 {
   boost::optional<bool> setAA{boost::none};
@@ -78,6 +80,7 @@ public:
 
   ResponseConfig d_responseConfig;
 private:
+  static thread_local std::default_random_engine t_randomEngine;
   std::vector<ComboAddress> d_addrs;
   std::set<uint16_t> d_types;
   std::string d_rawResponse;