From d56e60139a8c8f9fad434917ea236e8d2b1ea5ae Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 1 Dec 2005 23:59:40 +0000 Subject: Multithreaded DNS -- not tested!!!! git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2088 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dns.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/dns.cpp') diff --git a/src/dns.cpp b/src/dns.cpp index bc2ca8c17..738fd0116 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -667,7 +667,13 @@ bool DNS::ReverseLookup(std::string ip) bool DNS::ForwardLookup(std::string host) { - return false; + statsDns++; + this->fd = dns_getip4(host.c_str()); + if (this->fd == -1) + { + return false; + } + return true; } bool DNS::HasResult() @@ -693,6 +699,30 @@ std::string DNS::GetResult() return result; } else { statsDnsBad++; + if (this->fd != -1) + { + dns_close(this->fd); + } + return ""; + } +} + +std::string DNS::GetResultIP() +{ + char r[1024]; + result = dns_getresult(this->fd); + if (this->fd != -1) + { + dns_close(this->fd); + } + if (result) + { + sprintf(r,"%d.%d.%d.%d",result[0],result[1],result[2],result[3]); + return r; + } + else + { + log(DEBUG,"DANGER WILL ROBINSON! NXDOMAIN for forward lookup, but we got a reverse lookup!"); return ""; } } -- cgit v1.2.3