summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-02 21:39:12 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-02 21:39:12 +0000
commitbe9ffd24301fedb5aadb8657fe46bc0d52fa88db (patch)
tree7b2226b3f6d2c4aa5c98c9731d05be10925f9cbf /src/dns.cpp
parentdaf12f4d06f7815d01d3a8c3d6dfd0e0007a7ba6 (diff)
Allocate request id's in sequence, which means we wont get a duplicate id until 65536 id's have been given out.
Much safer than rand() git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4659 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 425c124c4..652bd9838 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -202,7 +202,9 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
/* Add a query with a predefined header, and allocate an ID for it. */
DNSRequest* DNS::AddQuery(DNSHeader *header, int &id)
{
- id = rand() % 65536;
+ id = this->currid++;
+ this->currid &= 0xFFFF;
+
DNSRequest* req = new DNSRequest(this->myserver);
header->id[0] = req->id[0] = id >> 8;
@@ -234,10 +236,9 @@ DNS::DNS()
/* Clear the Resolver class table */
memset(Classes,0,sizeof(Classes));
- /* Seed random number generator, we use this to generate
- * dns packet id's
+ /* Set the id of the next request to 0
*/
- srand((unsigned int)time(NULL));
+ currid = 0;
/* Clear the namesever address */
memset(&myserver,0,sizeof(insp_inaddr));