#include <arpa/inet.h>
#else
#include "inspircd_win32wrapper.h"
+#include "inspircd_se_config.h"
#endif
#include "dns.h"
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
*/
/* 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)
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)
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;
* as the last parameter on the line with a value ":1".
*/
if (*formatted == ':')
- resultstr = "0" + resultstr;
+ resultstr.insert(0, "0");
}
break;
/** Generate pseudo-random number */
unsigned long DNS::PRNG()
{
-#ifndef WIN32
unsigned long val = 0;
timeval n;
serverstats* s = ServerInstance->stats;
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
}