return valrandom(random(), servers, remote, qname, qtype, dh);
}
+static uint32_t g_hashperturb;
shared_ptr<DownstreamState> whashed(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh)
{
- return valrandom(qname.hash(), servers, remote, qname, qtype, dh);
+ return valrandom(qname.hash(g_hashperturb), servers, remote, qname, qtype, dh);
}
openlog("dnsdist", LOG_PID, LOG_DAEMON);
g_console=true;
+
#ifdef HAVE_LIBSODIUM
if (sodium_init() == -1) {
cerr<<"Unable to initialize crypto library"<<endl;
exit(EXIT_FAILURE);
}
+ g_hashperturb=randombytes_uniform(0xffffffff);
+ srandom(randombytes_uniform(0xffffffff));
+#else
+ {
+ struct timeval tv;
+ gettimeofday(&tv, 0);
+ srandom(tv.tv_sec ^ tv.tv_usec ^ getpid());
+ g_hashperturb=random();
+ }
+
#endif
g_cmdLine.config=SYSCONFDIR "/dnsdist.conf";
struct option longopts[]={
bool isRoot() const { return d_storage.size()==1 && d_storage[0]==0; }
void clear() { d_storage.clear(); }
void trimToLabels(unsigned int);
- size_t hash() const
+ size_t hash(size_t init=0) const
{
- return burtleCI((const unsigned char*)d_storage.c_str(), d_storage.size(), 0);
+ return burtleCI((const unsigned char*)d_storage.c_str(), d_storage.size(), init);
}
DNSName& operator+=(const DNSName& rhs)
{