]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Fix for bug #646, reported by whotookspaz (+y not being applied to existing channels...
[user/henk/code/inspircd.git] / src / dns.cpp
index 2e393de537f12954862bf5b55e3d57e222b52389..85d620982630435ca0e604a5993a8b81e1ce998f 100644 (file)
@@ -11,7 +11,7 @@
  * ---------------------------------------------------
  */
 
-/* $Core: libIRCDasyncdns */
+/* $Core */
 
 /*
 dns.cpp - Nonblocking DNS functions.
@@ -40,11 +40,6 @@ looks like this, walks like this or tastes like this.
 #include "configreader.h"
 #include "socket.h"
 
-using irc::sockets::insp_inaddr;
-using irc::sockets::insp_ntoa;
-using irc::sockets::insp_aton;
-using irc::sockets::OpenTCPSocket;
-
 /** Masks to mask off the responses we get from the DNSRequest methods
  */
 enum QueryInfo
@@ -131,7 +126,7 @@ class RequestTimeout : public Timer
        DNSRequest* watch;
        int watchid;
  public:
-       RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, time(NULL)), ServerInstance(SI), watch(watching), watchid(id)
+       RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id) : Timer(n, SI->Time()), ServerInstance(SI), watch(watching), watchid(id)
        {
        }
 
@@ -355,7 +350,7 @@ void DNS::Rehash()
 #endif
 
        /* Initialize mastersocket */
-       int s = OpenTCPSocket(ServerInstance->Config->DNSServer, SOCK_DGRAM);
+       int s = irc::sockets::OpenTCPSocket(ServerInstance->Config->DNSServer, SOCK_DGRAM);
        this->SetFd(s);
        ServerInstance->SE->NonBlocking(this->GetFd());
 
@@ -517,7 +512,7 @@ int DNS::GetCName(const char *alias)
 }
 
 /** Start lookup of an IP address to a hostname */
-int DNS::GetName(const insp_inaddr *ip)
+int DNS::GetName(const irc::sockets::insp_inaddr *ip)
 {
        char query[128];
        DNSHeader h;
@@ -540,7 +535,7 @@ int DNS::GetName(const insp_inaddr *ip)
        if ((length = this->MakePayload(query, DNS_QUERY_PTR, 1, (unsigned char*)&h.payload)) == -1)
                return -1;
 
-       DNSRequest* req = this->AddQuery(&h, id, insp_ntoa(*ip));
+       DNSRequest* req = this->AddQuery(&h, id, irc::sockets::insp_ntoa(*ip));
 
        if ((!req) || (req->SendRequests(&h, length, DNS_QUERY_PTR) == -1))
                return -1;
@@ -934,7 +929,6 @@ DNS::~DNS()
        ServerInstance->SE->Shutdown(this, 2);
        ServerInstance->SE->Close(this);
        ServerInstance->Timers->DelTimer(this->PruneTimer);
-       delete this->PruneTimer;
 }
 
 CachedQuery* DNS::GetCache(const std::string &source)
@@ -978,7 +972,7 @@ Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt,
                }
        }
 
-       insp_inaddr binip;
+       irc::sockets::insp_inaddr binip;
 
        switch (querytype)
        {
@@ -987,7 +981,7 @@ Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt,
                break;
 
                case DNS_QUERY_PTR:
-                       if (insp_aton(source.c_str(), &binip) > 0)
+                       if (irc::sockets::insp_aton(source.c_str(), &binip) > 0)
                        {
                                /* Valid ip address */
                                this->myid = ServerInstance->Res->GetName(&binip);
@@ -1170,8 +1164,8 @@ unsigned long DNS::PRNG()
        timeval n;
        serverstats* s = ServerInstance->stats;
        gettimeofday(&n,NULL);
-       val = (n.tv_usec ^ getpid() ^ geteuid() ^ (this->currid++)) ^ s->statsAccept + n.tv_sec;
-       val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad;
+       val = (n.tv_usec ^ (getpid() ^ geteuid()) ^ ((this->currid++)) ^ s->statsAccept) + n.tv_sec;
+       val = val + (s->statsCollisions ^ s->statsDnsGood) - s->statsDnsBad;
        val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size();
        return val;
 }