From 898e8da56573c70524a926c1df5dbab7ffcca6a5 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 16 Dec 2005 09:56:33 +0000 Subject: Moved command parsing crap into command_parse.cpp git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2505 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dns.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/dns.cpp') 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 -- cgit v1.2.3