summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 5a70bb41d..d8018656e 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -764,3 +764,45 @@ std::string DNS::GetResultIP()
}
}
+
+
+#ifdef THREADED_DNS
+void* dns_task(void* arg)
+{
+ userrec* u = (userrec*)arg;
+ log(DEBUG,"DNS thread for user %s",u->nick);
+ DNS dns1;
+ DNS dns2;
+ std::string host;
+ std::string ip;
+ if (dns1.ReverseLookup(u->ip))
+ {
+ while (!dns1.HasResult())
+ {
+ usleep(100);
+ }
+ host = dns1.GetResult();
+ if (host != "")
+ {
+ if (dns2.ForwardLookup(host))
+ {
+ while (!dns2.HasResult())
+ {
+ usleep(100);
+ }
+ ip = dns2.GetResultIP();
+ if (ip == std::string(u->ip))
+ {
+ if (host.length() < 160)
+ {
+ strcpy(u->host,host.c_str());
+ strcpy(u->dhost,host.c_str());
+ }
+ }
+ }
+ }
+ }
+ u->dns_done = true;
+ return NULL;
+}
+#endif