equal
deleted
inserted
replaced
30 local has_pposix, pposix = pcall(require, "util.pposix"); |
30 local has_pposix, pposix = pcall(require, "util.pposix"); |
31 |
31 |
32 local commands = module:shared("commands") |
32 local commands = module:shared("commands") |
33 local def_env = module:shared("env"); |
33 local def_env = module:shared("env"); |
34 local default_env_mt = { __index = def_env }; |
34 local default_env_mt = { __index = def_env }; |
35 local core_post_stanza = prosody.core_post_stanza; |
|
36 |
35 |
37 local function redirect_output(_G, session) |
36 local function redirect_output(_G, session) |
38 local env = setmetatable({ print = session.print }, { __index = function (t, k) return rawget(_G, k); end }); |
37 local env = setmetatable({ print = session.print }, { __index = function (t, k) return rawget(_G, k); end }); |
39 env.dofile = function(name) |
38 env.dofile = function(name) |
40 local f, err = envloadfile(name, env); |
39 local f, err = envloadfile(name, env); |
1097 def_env.xmpp = {}; |
1096 def_env.xmpp = {}; |
1098 |
1097 |
1099 local st = require "util.stanza"; |
1098 local st = require "util.stanza"; |
1100 function def_env.xmpp:ping(localhost, remotehost) |
1099 function def_env.xmpp:ping(localhost, remotehost) |
1101 if hosts[localhost] then |
1100 if hosts[localhost] then |
1102 core_post_stanza(hosts[localhost], |
1101 module:send(st.iq{ from=localhost, to=remotehost, type="get", id="ping" } |
1103 st.iq{ from=localhost, to=remotehost, type="get", id="ping" } |
1102 :tag("ping", {xmlns="urn:xmpp:ping"}), hosts[localhost]); |
1104 :tag("ping", {xmlns="urn:xmpp:ping"})); |
|
1105 return true, "Sent ping"; |
1103 return true, "Sent ping"; |
1106 else |
1104 else |
1107 return nil, "No such host"; |
1105 return nil, "No such host"; |
1108 end |
1106 end |
1109 end |
1107 end |