From b05ec98945e2eaf88d73ae68b91a3c9f31e8c4a1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 14 Dec 2010 18:28:42 +0000 Subject: net.dns: Add resolver:tohostname() and dns.tohostname() --- net/dns.lua | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- cgit v1.2.3