X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdns.cpp;h=49cfa3f1fbc3b380b83cef6b8fcc4654858a3a58;hb=46ff0bed0047c4cd05828c5f46dce63176e5084b;hp=a3e1a8b171ddd8a55d1698aade2e348c2ba3855d;hpb=b2073ba0ffc873b669c1f25a2352ad3dfdf13a5c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dns.cpp b/src/dns.cpp index a3e1a8b17..49cfa3f1f 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -21,18 +21,22 @@ Please do not assume that firedns works like this, looks like this, walks like this or tastes like this. */ +#ifndef WIN32 #include #include #include #include #include +#else +#include "inspircd_win32wrapper.h" +#endif + #include "dns.h" #include "inspircd.h" #include "socketengine.h" #include "configreader.h" #include "socket.h" -using irc::sockets::insp_sockaddr; using irc::sockets::insp_inaddr; using irc::sockets::insp_ntoa; using irc::sockets::insp_aton; @@ -239,7 +243,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 @@ -541,7 +545,6 @@ int DNS::GetName(const insp_inaddr *ip) /** Start lookup of an IP address to a hostname */ int DNS::GetNameForce(const char *ip, ForceProtocol fp) { - ServerInstance->Log(DEBUG,"GetNameForce: %s", ip); char query[128]; DNSHeader h; int id; @@ -552,7 +555,6 @@ int DNS::GetNameForce(const char *ip, ForceProtocol fp) in6_addr i; if (inet_pton(AF_INET6, ip, &i) > 0) { - ServerInstance->Log(DEBUG,"Resolve to ipv6"); DNS::MakeIP6Int(query, &i); } else @@ -565,7 +567,6 @@ int DNS::GetNameForce(const char *ip, ForceProtocol fp) in_addr i; if (inet_aton(ip, &i)) { - ServerInstance->Log(DEBUG,"Resolve to ipv4"); unsigned char* c = (unsigned char*)&i.s_addr; sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[3],c[2],c[1],c[0]); } @@ -623,9 +624,7 @@ DNSResult DNS::GetResult() const char* ipaddr_from; unsigned short int port_from = 0; - int length = recvfrom(this->GetFd(),buffer,sizeof(DNSHeader),0,from,&x); - - ServerInstance->Log(DEBUG,"Recv %d.", length); + int length = recvfrom(this->GetFd(),(char*)buffer,sizeof(DNSHeader),0,from,&x); /* Did we get the whole header? */ if (length < 12) @@ -670,7 +669,6 @@ DNSResult DNS::GetResult() { if ((port_from != DNS::QUERY_PORT) || (strcasecmp(ipaddr_from, ServerInstance->Config->DNSServer))) { - ServerInstance->Log(DEBUG,"Doesnt match security: port_from=%d ipaddr_from=%s",port_from,ipaddr_from); return DNSResult(-1,"",0,""); } } @@ -1060,7 +1058,6 @@ Module* Resolver::GetCreator() /** Process a socket read event */ void DNS::HandleEvent(EventType et, int errornum) { - ServerInstance->Log(DEBUG,"Marshall dns reads"); /* Fetch the id and result of the next available packet */ DNSResult res = this->GetResult(); /* Is there a usable request id? */ @@ -1154,13 +1151,22 @@ 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; 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 += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - s->BoundPortCount; + 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 }