comparison plugins/mod_admin_shell.lua @ 14000:071779f7645c

Merge 13.0->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 05 Dec 2025 17:53:52 +0100
parents d539016e6b21 5ad86978ae78
children 0dd917830523
comparison
equal deleted inserted replaced
13998:d539016e6b21 14000:071779f7645c
2095 def_env.xmpp = new_section("Commands for sending XMPP stanzas"); 2095 def_env.xmpp = new_section("Commands for sending XMPP stanzas");
2096 2096
2097 describe_command [[xmpp:ping(localjid, remotejid) - Sends a ping to an XMPP entity and reports the response]] 2097 describe_command [[xmpp:ping(localjid, remotejid) - Sends a ping to an XMPP entity and reports the response]]
2098 local new_id = require "prosody.util.id".medium; 2098 local new_id = require "prosody.util.id".medium;
2099 function def_env.xmpp:ping(localjid, remotejid, timeout) 2099 function def_env.xmpp:ping(localjid, remotejid, timeout)
2100 local localhost, localresource = select(2, jid_split(localjid)); 2100 local localnode, localhost, localresource = jid_split(localjid);
2101 local remotehost = select(2, jid_split(remotejid)); 2101 local remotenode, remotehost, remoteresource = jid_split(remotejid);
2102 if not localhost then 2102 if not localhost then
2103 return nil, "Invalid sender JID"; 2103 return nil, "Invalid sender JID";
2104 elseif not prosody.hosts[localhost] then 2104 elseif not prosody.hosts[localhost] then
2105 return nil, "No such local host"; 2105 return nil, "No such local host";
2106 elseif localresource then 2106 elseif localresource then
2107 return nil, "Server can't send ping from local resource"; -- Would require creating a temporary session with bound resource and everything 2107 return nil, "Server can't send ping from local resource"; -- Would require creating a temporary session with bound resource and everything
2108 end 2108 end
2109 if not remotehost then 2109 if not remotehost then
2110 return nil, "Invalid destination JID"; 2110 return nil, "Invalid destination JID";
2111 end 2111 end
2112 local iq = st.iq{ from=localjid, to=remotejid, type="get", id=new_id()} 2112 local iq = st.iq { from = jid_join(localnode, localhost); to = jid_join(remotenode, remotehost, remoteresource); type = "get"; id = new_id() }
2113 :tag("ping", {xmlns="urn:xmpp:ping"}); 2113 :tag("ping", {xmlns="urn:xmpp:ping"});
2114 local time_start = time.now(); 2114 local time_start = time.now();
2115 local print = self.session.print; 2115 local print = self.session.print;
2116 local function onchange(what) 2116 local function onchange(what)
2117 return function(event) 2117 return function(event)