# HG changeset patch # User Kim Alvefur # Date 1579904954 -3600 # Node ID 09d98cd38fe2ed220d31e20858f097e43893da0d # Parent ef620906ab826f5e27ca78a5ce4dea9a1eb69c6c mod_admin_telnet: Use promise based DNS resolving Mostly done for testing this new API diff -r ef620906ab82 -r 09d98cd38fe2 plugins/mod_admin_telnet.lua --- a/plugins/mod_admin_telnet.lua Fri Jan 24 23:28:15 2020 +0100 +++ b/plugins/mod_admin_telnet.lua Fri Jan 24 23:29:14 2020 +0100 @@ -1189,14 +1189,12 @@ 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(...); + local ret, err = async.wait(resolver:lookup_promise(name, typ, class)); + if ret then + return true, ret; + elseif err then + return false, err; end - resolver:lookup(handler, name, typ, class); - return true, ret; end function def_env.dns:addnameserver(...)