Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 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 |
parent | 10619:ef620906ab82 |
child | 10644:6c4ab1b87588 |
comparison
equal
deleted
inserted
replaced
10619:ef620906ab82 | 10620:09d98cd38fe2 |
---|---|
1187 return resolver; | 1187 return resolver; |
1188 end | 1188 end |
1189 | 1189 |
1190 function def_env.dns:lookup(name, typ, class) | 1190 function def_env.dns:lookup(name, typ, class) |
1191 local resolver = get_resolver(self.session); | 1191 local resolver = get_resolver(self.session); |
1192 local ret = "Query sent"; | 1192 local ret, err = async.wait(resolver:lookup_promise(name, typ, class)); |
1193 local print = self.session.print; | 1193 if ret then |
1194 local function handler(...) | 1194 return true, ret; |
1195 ret = "Got response"; | 1195 elseif err then |
1196 print(...); | 1196 return false, err; |
1197 end | 1197 end |
1198 resolver:lookup(handler, name, typ, class); | |
1199 return true, ret; | |
1200 end | 1198 end |
1201 | 1199 |
1202 function def_env.dns:addnameserver(...) | 1200 function def_env.dns:addnameserver(...) |
1203 local resolver = get_resolver(self.session); | 1201 local resolver = get_resolver(self.session); |
1204 resolver._resolver:addnameserver(...) | 1202 resolver._resolver:addnameserver(...) |