# HG changeset patch # User Kim Alvefur # Date 1579904895 -3600 # Node ID ef620906ab826f5e27ca78a5ce4dea9a1eb69c6c # Parent 8941bebd64e4c15f7756d151cb0af70332ad7e2c# Parent 2328413737116566dfef170952cf5b38955f7244 Merge 0.11->trunk diff -r 8941bebd64e4 -r ef620906ab82 plugins/mod_admin_telnet.lua --- a/plugins/mod_admin_telnet.lua Fri Jan 24 16:57:25 2020 +0000 +++ b/plugins/mod_admin_telnet.lua Fri Jan 24 23:28:15 2020 +0100 @@ -1177,36 +1177,49 @@ def_env.dns = {}; local adns = require"net.adns"; -local dns = require"net.dns"; + +local function get_resolver(session) + local resolver = session.dns_resolver; + if not resolver then + resolver = adns.resolver(); + session.dns_resolver = resolver; + end + return resolver; +end function def_env.dns:lookup(name, typ, class) + local resolver = get_resolver(self.session); local ret = "Query sent"; local print = self.session.print; local function handler(...) ret = "Got response"; print(...); end - adns.lookup(handler, name, typ, class); + resolver:lookup(handler, name, typ, class); return true, ret; end function def_env.dns:addnameserver(...) - dns._resolver:addnameserver(...) + local resolver = get_resolver(self.session); + resolver._resolver:addnameserver(...) return true end function def_env.dns:setnameserver(...) - dns._resolver:setnameserver(...) + local resolver = get_resolver(self.session); + resolver._resolver:setnameserver(...) return true end function def_env.dns:purge() - dns.purge() + local resolver = get_resolver(self.session); + resolver._resolver:purge() return true end function def_env.dns:cache() - return true, "Cache:\n"..tostring(dns.cache()) + local resolver = get_resolver(self.session); + return true, "Cache:\n"..tostring(resolver._resolver.cache) end def_env.http = {};