sillyrecords.cc \
statbag.cc \
unix_utility.cc \
- utility.hh
+ utility.hh \
+ uuid-utils.hh uuid-utils.cc
nodist_dnspcap2protobuf_SOURCES=dnsmessage.pb.cc dnsmessage.pb.h
{
#ifdef HAVE_PROTOBUF
if (!dq->uniqueId) {
- dq->uniqueId = t_uuidGenerator();
+ dq->uniqueId = getUniqueID();
}
DNSDistProtoBufMessage message(*dq);
{
#ifdef HAVE_PROTOBUF
if (!dr->uniqueId) {
- dr->uniqueId = t_uuidGenerator();
+ dr->uniqueId = getUniqueID();
}
DNSDistProtoBufMessage message(*dr, d_includeCNAME);
static boost::uuids::uuid makeRuleID(std::string& id)
{
if (id.empty()) {
- return t_uuidGenerator();
+ return getUniqueID();
}
- boost::uuids::string_generator gen;
- return gen(id);
+ return getUniqueID(id);
}
void parseRuleParams(boost::optional<luaruleparams_t> params, boost::uuids::uuid& uuid, uint64_t& creationOrder)
setLuaSideEffect();
auto rules = someRulActions->getCopy();
if (auto str = boost::get<std::string>(&id)) {
- boost::uuids::string_generator gen;
- const auto uuid = gen(*str);
+ const auto uuid = getUniqueID(*str);
if (rules.erase(std::remove_if(rules.begin(),
rules.end(),
[uuid](const T& a) { return a.d_id == uuid; }),
#ifdef HAVE_PROTOBUF
#include "dnsmessage.pb.h"
-DNSDistProtoBufMessage::DNSDistProtoBufMessage(const DNSQuestion& dq): DNSProtoBufMessage(Query, dq.uniqueId ? *dq.uniqueId : t_uuidGenerator(), dq.remote, dq.local, *dq.qname, dq.qtype, dq.qclass, dq.dh->id, dq.tcp, dq.len)
+DNSDistProtoBufMessage::DNSDistProtoBufMessage(const DNSQuestion& dq): DNSProtoBufMessage(Query, dq.uniqueId ? *dq.uniqueId : getUniqueID(), dq.remote, dq.local, *dq.qname, dq.qtype, dq.qclass, dq.dh->id, dq.tcp, dq.len)
{
setQueryTime(dq.queryTime->tv_sec, dq.queryTime->tv_nsec / 1000);
};
-DNSDistProtoBufMessage::DNSDistProtoBufMessage(const DNSResponse& dr, bool includeCNAME): DNSProtoBufMessage(Response, dr.uniqueId ? *dr.uniqueId : t_uuidGenerator(), dr.remote, dr.local, *dr.qname, dr.qtype, dr.qclass, dr.dh->id, dr.tcp, dr.len)
+DNSDistProtoBufMessage::DNSDistProtoBufMessage(const DNSResponse& dr, bool includeCNAME): DNSProtoBufMessage(Response, dr.uniqueId ? *dr.uniqueId : getUniqueID(), dr.remote, dr.local, *dr.qname, dr.qtype, dr.qclass, dr.dh->id, dr.tcp, dr.len)
{
setQueryTime(dr.queryTime->tv_sec, dr.queryTime->tv_nsec / 1000);
setResponseCode(dr.dh->rcode);
#include "sstuff.hh"
#include "threadname.hh"
-thread_local boost::uuids::random_generator t_uuidGenerator;
-
/* Known sins:
Receiver is currently single threaded
DownstreamState::DownstreamState(const ComboAddress& remote_, const ComboAddress& sourceAddr_, unsigned int sourceItf_, size_t numberOfSockets): remote(remote_), sourceAddr(sourceAddr_), sourceItf(sourceItf_)
{
pthread_rwlock_init(&d_lock, nullptr);
- id = t_uuidGenerator();
+ id = getUniqueID();
threadStarted.clear();
mplexer = std::unique_ptr<FDMultiplexer>(FDMultiplexer::getMultiplexerSilent());
#include "mplexer.hh"
#include "sholder.hh"
#include "tcpiohandler.hh"
-
-#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
-#include <boost/uuid/uuid_io.hpp>
+#include "uuid-utils.hh"
void carbonDumpThread();
uint64_t uptimeOfProcess(const std::string& str);
extern uint16_t g_ECSSourcePrefixV6;
extern bool g_ECSOverride;
-extern thread_local boost::uuids::random_generator t_uuidGenerator;
-
typedef std::unordered_map<string, string> QTag;
struct DNSQuestion
statnode.cc statnode.hh \
tcpiohandler.cc tcpiohandler.hh \
threadname.hh threadname.cc \
+ uuid-utils.hh uuid-utils.cc \
xpf.cc xpf.hh \
ext/luawrapper/include/LuaContext.hpp \
ext/json11/json11.cpp \
--- /dev/null
+../uuid-utils.cc
\ No newline at end of file
--- /dev/null
+../uuid-utils.hh
\ No newline at end of file
#include "config.h"
#endif
#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
#include "iputils.hh"
#include "misc.hh"
#include "dnspcap.hh"
#include "dnsparser.hh"
#include "protobuf.hh"
+#include "uuid-utils.hh"
#include "statbag.hh"
StatBag S;
ind=atoi(argv[3]);
std::map<uint16_t,std::pair<boost::uuids::uuid,struct timeval> > ids;
- boost::uuids::random_generator uuidGenerator;
try {
while (pr.getUDPPacket()) {
const dnsheader* dh=(dnsheader*)pr.d_payload;
if (!dh->qr) {
queryTime.tv_sec = pr.d_pheader.ts.tv_sec;
queryTime.tv_usec = pr.d_pheader.ts.tv_usec;
- uniqueId = uuidGenerator();
+ uniqueId = getUniqueID();
ids[dh->id] = std::make_pair(uniqueId, queryTime);
}
else {
hasQueryTime = true;
}
else {
- uniqueId = uuidGenerator();
+ uniqueId = getUniqueID();
}
}
#ifdef HAVE_PROTOBUF
#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
#include "dnstap.pb.h"
#endif /* HAVE_PROTOBUF */
protected:
dnstap::Dnstap proto_message;
#endif /* HAVE_PROTOBUF */
-};
\ No newline at end of file
+};
#ifdef HAVE_PROTOBUF
+#include "uuid-utils.hh"
+
static void logOutgoingQuery(const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, boost::optional<const boost::uuids::uuid&> initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional<Netmask>& srcmask)
{
if(!outgoingLoggers)
const struct timeval queryTime = *now;
if (outgoingLoggers) {
- uuid = (*t_uuidGenerator)();
+ uuid = getUniqueID();
logOutgoingQuery(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size(), srcmask);
}
#endif
#include "namespaces.hh"
+#ifdef HAVE_PROTOBUF
+#include "uuid-utils.hh"
+#endif
+
#include "xpf.hh"
typedef map<ComboAddress, uint32_t, ComboAddress::addressOnlyLessThan> tcpClientCounts_t;
thread_local std::unique_ptr<addrringbuf_t> t_remotes, t_servfailremotes, t_largeanswerremotes, t_bogusremotes;
thread_local std::unique_ptr<boost::circular_buffer<pair<DNSName, uint16_t> > > t_queryring, t_servfailqueryring, t_bogusqueryring;
thread_local std::shared_ptr<NetmaskGroup> t_allowFrom;
-#ifdef HAVE_PROTOBUF
-thread_local std::unique_ptr<boost::uuids::random_generator> t_uuidGenerator;
-#endif
#ifdef NOD_ENABLED
thread_local std::shared_ptr<nod::NODDB> t_nodDBp;
thread_local std::shared_ptr<nod::UniqueResponseDB> t_udrDBp;
if(t_protobufServers || t_outgoingProtobufServers) {
dc->d_requestorId = requestorId;
dc->d_deviceId = deviceId;
- dc->d_uuid = (*t_uuidGenerator)();
+ dc->d_uuid = getUniqueID();
}
if(t_protobufServers) {
boost::uuids::uuid uniqueId;
auto luaconfsLocal = g_luaconfs.getLocal();
if (checkProtobufExport(luaconfsLocal)) {
- uniqueId = (*t_uuidGenerator)();
+ uniqueId = getUniqueID();
needECS = true;
} else if (checkOutgoingProtobufExport(luaconfsLocal)) {
- uniqueId = (*t_uuidGenerator)();
+ uniqueId = getUniqueID();
}
logQuery = t_protobufServers && luaconfsLocal->protobufExportConfig.logQueries;
bool logResponse = t_protobufServers && luaconfsLocal->protobufExportConfig.logResponses;
t_packetCache = std::unique_ptr<RecursorPacketCache>(new RecursorPacketCache());
-#ifdef HAVE_PROTOBUF
- t_uuidGenerator = std::unique_ptr<boost::uuids::random_generator>(new boost::uuids::random_generator());
-#endif
g_log<<Logger::Warning<<"Done priming cache with root hints"<<endl;
#ifdef NOD_ENABLED
#ifdef HAVE_PROTOBUF
#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
#include "dnsmessage.pb.h"
#endif /* HAVE_PROTOBUF */
testrunner$(OBJEXT): dnsmessage.pb.cc
endif
+
+pdns_recursor_SOURCES += \
+ uuid-utils.hh uuid-utils.cc
+
endif
rec_control_SOURCES = \
--- /dev/null
+../uuid-utils.cc
\ No newline at end of file
--- /dev/null
+../uuid-utils.hh
\ No newline at end of file
#ifdef HAVE_PROTOBUF
#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
#endif
class RecursorLua4;
void primeHints(void);
extern __thread struct timeval g_now;
-
-#ifdef HAVE_PROTOBUF
-extern thread_local std::unique_ptr<boost::uuids::random_generator> t_uuidGenerator;
-#endif
--- /dev/null
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "uuid-utils.hh"
+
+// see https://github.com/boostorg/random/issues/49
+#if BOOST_VERSION == 106900
+#ifndef BOOST_PENDING_INTEGER_LOG2_HPP
+#define BOOST_PENDING_INTEGER_LOG2_HPP
+#include <boost/integer/integer_log2.hpp>
+#endif /* BOOST_PENDING_INTEGER_LOG2_HPP */
+#endif /* BOOST_VERSION */
+
+#include <boost/uuid/uuid_generators.hpp>
+
+thread_local boost::uuids::random_generator t_uuidGenerator;
+
+boost::uuids::uuid getUniqueID()
+{
+ return t_uuidGenerator();
+}
+
+boost::uuids::uuid getUniqueID(const std::string& str)
+{
+ boost::uuids::string_generator gen;
+ return gen(str);
+}
+
--- /dev/null
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#pragma once
+
+#include <boost/uuid/uuid.hpp>
+#include <boost/uuid/uuid_io.hpp>
+
+boost::uuids::uuid getUniqueID();
+boost::uuids::uuid getUniqueID(const std::string& str);