# HG changeset patch # User Matthew Wild # Date 1292351322 0 # Node ID 9719316c854e4dcff2d7e56eec67ec18d8f974a6 # Parent 87f6eabd90c9cb885af90b00f6b9e21d0ed932f3 net.dns: Add resolver:tohostname() and dns.tohostname() diff -r 87f6eabd90c9 -r 9719316c854e net/dns.lua --- a/net/dns.lua Mon Dec 13 20:45:08 2010 +0500 +++ b/net/dns.lua Tue Dec 14 18:28:42 2010 +0000 @@ -939,6 +939,9 @@ 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 @@ return _resolver:lookup(...); end +function dns.tohostname(...) + return _resolver:tohostname(...); +end + function dns.purge(...) -- - - - - - - - - - - - - - - - - - - - - - purge return _resolver:purge(...); end