Changeset

3746:9719316c854e

net.dns: Add resolver:tohostname() and dns.tohostname()
author Matthew Wild <mwild1@gmail.com>
date Tue, 14 Dec 2010 18:28:42 +0000
parents 3745:87f6eabd90c9
children 3747:7d5b135bf268
files net/dns.lua
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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