Comparison

plugins/mod_admin_shell.lua @ 10929:ad5e373b1419

mod_admin_shell: Update for async.wait_for rename
author Kim Alvefur <zash@zash.se>
date Sat, 13 Jun 2020 14:40:41 +0200
parent 10918:b0038e404e0e
child 10986:d585deb8c882
comparison
equal deleted inserted replaced
10928:79faf5b98395 10929:ad5e373b1419
1158 return nil, "Both hosts are local"; 1158 return nil, "Both hosts are local";
1159 end 1159 end
1160 local iq = st.iq{ from=localhost, to=remotehost, type="get", id=new_id()} 1160 local iq = st.iq{ from=localhost, to=remotehost, type="get", id=new_id()}
1161 :tag("ping", {xmlns="urn:xmpp:ping"}); 1161 :tag("ping", {xmlns="urn:xmpp:ping"});
1162 local time_start = time.now(); 1162 local time_start = time.now();
1163 local ret, err = async.wait(module:context(localhost):send_iq(iq, nil, timeout)); 1163 local ret, err = async.wait_for(module:context(localhost):send_iq(iq, nil, timeout));
1164 if ret then 1164 if ret then
1165 return true, ("pong from %s in %gs"):format(ret.stanza.attr.from, time.now() - time_start); 1165 return true, ("pong from %s in %gs"):format(ret.stanza.attr.from, time.now() - time_start);
1166 else 1166 else
1167 return false, tostring(err); 1167 return false, tostring(err);
1168 end 1168 end
1180 return resolver; 1180 return resolver;
1181 end 1181 end
1182 1182
1183 function def_env.dns:lookup(name, typ, class) 1183 function def_env.dns:lookup(name, typ, class)
1184 local resolver = get_resolver(self.session); 1184 local resolver = get_resolver(self.session);
1185 local ret, err = async.wait(resolver:lookup_promise(name, typ, class)); 1185 local ret, err = async.wait_for(resolver:lookup_promise(name, typ, class));
1186 if ret then 1186 if ret then
1187 return true, ret; 1187 return true, ret;
1188 elseif err then 1188 elseif err then
1189 return false, err; 1189 return false, err;
1190 end 1190 end