diff options
Diffstat (limited to 'src/dns.cpp')
-rw-r--r-- | src/dns.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/dns.cpp b/src/dns.cpp index dee83d3ac..8526d5be2 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -242,11 +242,9 @@ DNSRequest* DNS::AddQuery(DNSHeader *header, int &id, const char* original) return NULL; /* Create an id */ - id = this->PRNG() & DNS::MAX_REQUEST_ID; - - /* If this id is already 'in flight', pick another. */ - while (requests[id]) - id = this->PRNG() & DNS::MAX_REQUEST_ID; + do { + id = ServerInstance->GenRandomInt(DNS::MAX_REQUEST_ID); + } while (requests[id]); DNSRequest* req = new DNSRequest(this, id, original); @@ -1041,14 +1039,3 @@ void DNS::CleanResolvers(Module* module) } } } - -/** Generate pseudo-random number */ -unsigned long DNS::PRNG() -{ - unsigned long val = 0; - serverstats* s = ServerInstance->stats; - val = (rand() ^ this->currid++ ^ s->statsAccept) + ServerInstance->Time_ns(); - val += (s->statsCollisions ^ s->statsDnsGood) * s->statsDnsBad; - val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv); - return val; -} |