aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-12-14 18:28:42 +0000
committerMatthew Wild <mwild1@gmail.com>2010-12-14 18:28:42 +0000
commita99ff085ab056e54e1ba40227347f6e696a2aab7 (patch)
tree5c142da67907c208659bc806bee2ba2ca6580a6f
parentde4152ae6df819fea2bc68ff73301d9b85b3a708 (diff)
downloadprosody-a99ff085ab056e54e1ba40227347f6e696a2aab7.tar.gz
prosody-a99ff085ab056e54e1ba40227347f6e696a2aab7.zip
net.dns: Add resolver:tohostname() and dns.tohostname()
-rw-r--r--net/dns.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/dns.lua b/net/dns.lua
index c0875b5a..f3d80291 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -939,6 +939,9 @@ function resolver:lookupex(handler, qname, qtype, qclass) -- - - - - - - - -
return self:peek(qname, qtype, qclass) or self:query(qname, qtype, qclass);
end
+function resolver:tohostname(ip)
+ return dns.lookup(ip:gsub("(%d+)%.(%d+)%.(%d+)%.(%d+)", "%4.%3.%2.%1.in-addr.arpa."), "PTR");
+end
--print ---------------------------------------------------------------- print
@@ -1014,6 +1017,10 @@ function dns.lookup(...) -- - - - - - - - - - - - - - - - - - - - - lookup
return _resolver:lookup(...);
end
+function dns.tohostname(...)
+ return _resolver:tohostname(...);
+end
+
function dns.purge(...) -- - - - - - - - - - - - - - - - - - - - - - purge
return _resolver:purge(...);
end