diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-12-14 18:28:42 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-12-14 18:28:42 +0000 |
commit | b05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1 (patch) | |
tree | 17cd41e20cbfc27b92be9c7690d0b96dde8eddb6 | |
parent | 40e3e8175b1363f4ebf73aa30c030fc6fb699a25 (diff) | |
download | prosody-b05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1.tar.gz prosody-b05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1.zip |
net.dns: Add resolver:tohostname() and dns.tohostname()
-rw-r--r-- | net/dns.lua | 7 |
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 |