Comparison

plugins/mod_admin_telnet.lua @ 9734:cc01bb7a3305

mod_admin_telnet: Invert host existence check Simplifies and reduces indentation
author Kim Alvefur <zash@zash.se>
date Fri, 28 Dec 2018 20:56:01 +0100
parent 9711:39dc037875e1
child 9735:2d8ca54ecbc6
comparison
equal deleted inserted replaced
9733:9ab9aabafa80 9734:cc01bb7a3305
1065 1065
1066 def_env.xmpp = {}; 1066 def_env.xmpp = {};
1067 1067
1068 local st = require "util.stanza"; 1068 local st = require "util.stanza";
1069 function def_env.xmpp:ping(localhost, remotehost) 1069 function def_env.xmpp:ping(localhost, remotehost)
1070 if prosody.hosts[localhost] then 1070 if not prosody.hosts[localhost] then
1071 module:send(st.iq{ from=localhost, to=remotehost, type="get", id="ping" }
1072 :tag("ping", {xmlns="urn:xmpp:ping"}), prosody.hosts[localhost]);
1073 return true, "Sent ping";
1074 else
1075 return nil, "No such host"; 1071 return nil, "No such host";
1076 end 1072 end
1073 module:send(st.iq{ from=localhost, to=remotehost, type="get", id="ping" }
1074 :tag("ping", {xmlns="urn:xmpp:ping"}), prosody.hosts[localhost]);
1075 return true, "Sent ping";
1077 end 1076 end
1078 1077
1079 def_env.dns = {}; 1078 def_env.dns = {};
1080 local adns = require"net.adns"; 1079 local adns = require"net.adns";
1081 local dns = require"net.dns"; 1080 local dns = require"net.dns";