Software /
code /
prosody
Comparison
net/dns.lua @ 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 |
parent | 3719:0f87632b87e9 |
child | 3747:7d5b135bf268 |
comparison
equal
deleted
inserted
replaced
3745:87f6eabd90c9 | 3746:9719316c854e |
---|---|
937 | 937 |
938 function resolver:lookupex(handler, qname, qtype, qclass) -- - - - - - - - - - lookup | 938 function resolver:lookupex(handler, qname, qtype, qclass) -- - - - - - - - - - lookup |
939 return self:peek(qname, qtype, qclass) or self:query(qname, qtype, qclass); | 939 return self:peek(qname, qtype, qclass) or self:query(qname, qtype, qclass); |
940 end | 940 end |
941 | 941 |
942 function resolver:tohostname(ip) | |
943 return dns.lookup(ip:gsub("(%d+)%.(%d+)%.(%d+)%.(%d+)", "%4.%3.%2.%1.in-addr.arpa."), "PTR"); | |
944 end | |
942 | 945 |
943 --print ---------------------------------------------------------------- print | 946 --print ---------------------------------------------------------------- print |
944 | 947 |
945 | 948 |
946 local hints = { -- - - - - - - - - - - - - - - - - - - - - - - - - - - hints | 949 local hints = { -- - - - - - - - - - - - - - - - - - - - - - - - - - - hints |
1012 | 1015 |
1013 function dns.lookup(...) -- - - - - - - - - - - - - - - - - - - - - lookup | 1016 function dns.lookup(...) -- - - - - - - - - - - - - - - - - - - - - lookup |
1014 return _resolver:lookup(...); | 1017 return _resolver:lookup(...); |
1015 end | 1018 end |
1016 | 1019 |
1020 function dns.tohostname(...) | |
1021 return _resolver:tohostname(...); | |
1022 end | |
1023 | |
1017 function dns.purge(...) -- - - - - - - - - - - - - - - - - - - - - - purge | 1024 function dns.purge(...) -- - - - - - - - - - - - - - - - - - - - - - purge |
1018 return _resolver:purge(...); | 1025 return _resolver:purge(...); |
1019 end | 1026 end |
1020 | 1027 |
1021 function dns.peek(...) -- - - - - - - - - - - - - - - - - - - - - - - peek | 1028 function dns.peek(...) -- - - - - - - - - - - - - - - - - - - - - - - peek |