aboutsummaryrefslogtreecommitdiffstats
path: root/net/dns.lua
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
commitb05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1 (patch)
tree17cd41e20cbfc27b92be9c7690d0b96dde8eddb6 /net/dns.lua
parent40e3e8175b1363f4ebf73aa30c030fc6fb699a25 (diff)
downloadprosody-b05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1.tar.gz
prosody-b05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1.zip
net.dns: Add resolver:tohostname() and dns.tohostname()
Diffstat (limited to 'net/dns.lua')
-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