Changeset

10620:09d98cd38fe2

mod_admin_telnet: Use promise based DNS resolving Mostly done for testing this new API
author Kim Alvefur <zash@zash.se>
date Fri, 24 Jan 2020 23:29:14 +0100
parents 10619:ef620906ab82
children 10621:e5ab31845094
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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(...)