]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Added the <cloak:ipalways> and <cloak:lowercase> options. Patch by nenolod
[user/henk/code/inspircd.git] / src / dns.cpp
index df79eba24096b1e255512ccddfb874d4237bd176..292ca00acb791311bd27e121f767b1b0101e0ac7 100644 (file)
@@ -29,6 +29,7 @@ looks like this, walks like this or tastes like this.
 #include <arpa/inet.h>
 #else
 #include "inspircd_win32wrapper.h"
+#include "inspircd_se_config.h"
 #endif
 
 #include "dns.h"
@@ -41,6 +42,7 @@ using irc::sockets::insp_inaddr;
 using irc::sockets::insp_ntoa;
 using irc::sockets::insp_aton;
 using irc::sockets::OpenTCPSocket;
+using irc::sockets::NonBlocking;
 
 /** Masks to mask off the responses we get from the DNSRequest methods
  */
@@ -358,6 +360,7 @@ void DNS::Rehash()
        /* Initialize mastersocket */
        int s = OpenTCPSocket(ServerInstance->Config->DNSServer, SOCK_DGRAM);
        this->SetFd(s);
+       NonBlocking(s);
 
        /* Have we got a socket and is it nonblocking? */
        if (this->GetFd() != -1)
@@ -624,7 +627,10 @@ DNSResult DNS::GetResult()
        const char* ipaddr_from;
        unsigned short int port_from = 0;
 
-       int length = recvfrom(this->GetFd(),(char*)buffer,sizeof(DNSHeader),0,from,&x);
+       void* m_readEvent = NULL;
+       GetExt("windows_readevent", m_readEvent);
+
+       int length = _recvfrom(this->GetFd(),(char*)buffer,sizeof(DNSHeader),0,from,&x);
 
        /* Did we get the whole header? */
        if (length < 12)
@@ -651,14 +657,11 @@ DNSResult DNS::GetResult()
                port_from = ntohs(((sockaddr_in6*)from)->sin6_port);
        }
        else
+#endif
        {
                ipaddr_from = inet_ntoa(((sockaddr_in*)from)->sin_addr);
                port_from = ntohs(((sockaddr_in*)from)->sin_port);
        }
-#else
-       ipaddr_from = inet_ntoa(((sockaddr_in*)from)->sin_addr);
-       port_from = ntohs(((sockaddr_in*)from)->sin_port);
-#endif
 
        delete[] from;
 
@@ -759,7 +762,7 @@ DNSResult DNS::GetResult()
                                 * as the last parameter on the line with a value ":1".
                                 */
                                if (*formatted == ':')
-                                       resultstr = "0" + resultstr;
+                                       resultstr.insert(0, "0");
                        }
                        break;
 
@@ -1151,7 +1154,6 @@ void DNS::CleanResolvers(Module* module)
 /** Generate pseudo-random number */
 unsigned long DNS::PRNG()
 {
-#ifndef WIN32
        unsigned long val = 0;
        timeval n;
        serverstats* s = ServerInstance->stats;
@@ -1160,13 +1162,5 @@ unsigned long DNS::PRNG()
        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;
-#else
-    unsigned long val = 0;
-    serverstats* s = ServerInstance->stats;
-    val = (time(NULL) ^ GetCurrentProcessId() ^ GetCurrentThreadId() ^ (this->currid++)) ^ s->statsAccept + time(NULL);
-    val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad;
-    val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv);
-    return val;
-#endif
 }