X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdns.cpp;h=3b8f8cc95426a7cf23febdb329b3aa384b5d9505;hb=59b1a8955142935b02af6446005ab47fc7c3fc8c;hp=f9411234dd21797b53cc69fb856120bb58e778a3;hpb=1383dba43e463f292aea094d01f62f355946049d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dns.cpp b/src/dns.cpp index f9411234d..3b8f8cc95 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -665,10 +665,10 @@ char* DNS::dns_getresult_s(const int cfd, char *res) { /* retrieve result of DNS alist->next = NULL; break; } - goto defaultcase; + memcpy(res,&h.payload[i],rr.rdlength); + res[rr.rdlength] = '\0'; break; default: - defaultcase: memcpy(res,&h.payload[i],rr.rdlength); res[rr.rdlength] = '\0'; break; @@ -735,6 +735,20 @@ bool DNS::ForwardLookup(std::string host) return true; } +bool DNS::ForwardLookupWithFD(std::string host, int &fd) +{ + ServerInstance->stats->statsDns++; + this->myfd = dns_getip4(host.c_str()); + fd = this->myfd; + if (this->myfd == -1) + { + + } + log(DEBUG,"DNS: ForwardLookupWithFD, fd=%d",this->myfd); + ServerInstance->SE->AddFd(this->myfd,true,X_ESTAB_MODULE); + return true; +} + bool DNS::HasResult(int fd) { return (fd == this->myfd); @@ -819,7 +833,7 @@ void* dns_task(void* arg) DNS dns2; std::string host; std::string ip; - if (dns1.ReverseLookup(u->ip)) + if (dns1.ReverseLookup((char*)inet_ntoa(u->ip4))) { while (!dns1.HasResult()) { @@ -835,7 +849,7 @@ void* dns_task(void* arg) usleep(100); } ip = dns2.GetResultIP(); - if (ip == std::string(u->ip)) + if (ip == std::string((char*)inet_ntoa(u->ip4))) { if (host.length() < 160) {