Software /
code /
prosody
Changeset
3866:0573cb708c25
net.dns: Add resolver:tohostname() and dns.tohostname()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 14 Dec 2010 18:28:42 +0000 |
parents | 3865:c6af5de97b37 |
children | 3867:f61693852711 |
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