From 77d574ac7d5feb51ef1353d6dcedaa055ea437d1 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 21 Apr 2020 14:36:12 +0200 Subject: [PATCH] In dnsdist, (which is not a dns_random consumer), use sdt::default_random_engine for shuffle. --- pdns/dnsdist-lua-actions.cc | 7 +++++-- pdns/dnsdist-lua.hh | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index c3e1e11360..9928fd680c 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -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); diff --git a/pdns/dnsdist-lua.hh b/pdns/dnsdist-lua.hh index 65bfec3fdc..b25be8840f 100644 --- a/pdns/dnsdist-lua.hh +++ b/pdns/dnsdist-lua.hh @@ -21,6 +21,8 @@ */ #pragma once +#include + struct ResponseConfig { boost::optional setAA{boost::none}; @@ -78,6 +80,7 @@ public: ResponseConfig d_responseConfig; private: + static thread_local std::default_random_engine t_randomEngine; std::vector d_addrs; std::set d_types; std::string d_rawResponse; -- 2.47.2