]> 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 c04ab4cc174e3de42164f76adbd674d3d5fbe054..292ca00acb791311bd27e121f767b1b0101e0ac7 100644 (file)
@@ -21,11 +21,17 @@ Please do not assume that firedns works like this,
 looks like this, walks like this or tastes like this.
 */
 
+#ifndef WIN32
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#else
+#include "inspircd_win32wrapper.h"
+#include "inspircd_se_config.h"
+#endif
+
 #include "dns.h"
 #include "inspircd.h"
 #include "socketengine.h"
@@ -36,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
  */
@@ -238,7 +245,7 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
        memcpy(&addr.sin_addr.s_addr, &dnsobj->myserver4, sizeof(addr.sin_addr));
        addr.sin_family = AF_INET;
        addr.sin_port = htons(DNS::QUERY_PORT);
-       if (sendto(dnsobj->GetFd(), payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12)
+       if (sendto(dnsobj->GetFd(), (const char*)payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12)
                return -1;
 #endif
 
@@ -353,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)
@@ -619,7 +627,10 @@ DNSResult DNS::GetResult()
        const char* ipaddr_from;
        unsigned short int port_from = 0;
 
-       int length = recvfrom(this->GetFd(),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)
@@ -646,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;
 
@@ -754,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;