summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-01 23:59:40 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-01 23:59:40 +0000
commitd56e60139a8c8f9fad434917ea236e8d2b1ea5ae (patch)
treebc908a0db845e41537067a4b7e43753f67894404 /src/dns.cpp
parent0ae2cb132ba4a631edbc232f483f72724856f5fb (diff)
Multithreaded DNS -- not tested!!!!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2088 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp32
1 files changed, 31 insertions, 1 deletions
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 "";
}
}