plugins/mod_console.lua

changeset 1240
397b6e9c1568
parent 1085
1ac11fb753ca
child 1241
9c53fb182044
equal deleted inserted replaced
1239:335d9a612477 1240:397b6e9c1568
193 193
194 function def_env.hosts:add(name) 194 function def_env.hosts:add(name)
195 end 195 end
196 196
197 def_env.s2s = {}; 197 def_env.s2s = {};
198 function def_env.s2s:show() 198 function def_env.s2s:show(match_jid)
199 local _print = self.session.print; 199 local _print = self.session.print;
200 local print = self.session.print; 200 local print = self.session.print;
201 for host, host_session in pairs(hosts) do 201 for host, host_session in pairs(hosts) do
202 print = function (...) _print(host); _print(...); print = _print; end 202 print = function (...) _print(host); _print(...); print = _print; end
203 for remotehost, session in pairs(host_session.s2sout) do 203 for remotehost, session in pairs(host_session.s2sout) do
204 print(" "..host.." -> "..remotehost); 204 if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then
205 if session.sendq then 205 print(" "..host.." -> "..remotehost);
206 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); 206 if session.sendq then
207 end 207 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection");
208 if session.type == "s2sout_unauthed" then 208 end
209 if session.connecting then 209 if session.type == "s2sout_unauthed" then
210 print(" Connection not yet established"); 210 if session.connecting then
211 if not session.srv_hosts then 211 print(" Connection not yet established");
212 if not session.conn then 212 if not session.srv_hosts then
213 print(" We do not yet have a DNS answer for this host's SRV records"); 213 if not session.conn then
214 else 214 print(" We do not yet have a DNS answer for this host's SRV records");
215 print(" This host has no SRV records, using A record instead"); 215 else
216 print(" This host has no SRV records, using A record instead");
217 end
218 elseif session.srv_choice then
219 print(" We are on SRV record "..session.srv_choice.." of "..#session.srv_hosts);
220 local srv_choice = session.srv_hosts[session.srv_choice];
221 print(" Using "..(srv_choice.target or ".")..":"..(srv_choice.port or 5269));
216 end 222 end
217 elseif session.srv_choice then 223 elseif session.notopen then
218 print(" We are on SRV record "..session.srv_choice.." of "..#session.srv_hosts); 224 print(" The <stream> has not yet been opened");
219 local srv_choice = session.srv_hosts[session.srv_choice]; 225 elseif not session.dialback_key then
220 print(" Using "..(srv_choice.target or ".")..":"..(srv_choice.port or 5269)); 226 print(" Dialback has not been initiated yet");
227 elseif session.dialback_key then
228 print(" Dialback has been requested, but no result received");
221 end 229 end
222 elseif session.notopen then 230 end
223 print(" The <stream> has not yet been opened"); 231 end
224 elseif not session.dialback_key then 232 end
225 print(" Dialback has not been initiated yet");
226 elseif session.dialback_key then
227 print(" Dialback has been requested, but no result received");
228 end
229 end
230 end
231 233
232 for session in pairs(incoming_s2s) do 234 for session in pairs(incoming_s2s) do
233 if session.to_host == host then 235 if session.to_host == host and ((not match_jid) or host:match(match_jid)
236 or (session.from_host and session.from_host:match(match_jid))) then
234 print(" "..host.." <- "..(session.from_host or "(unknown)")); 237 print(" "..host.." <- "..(session.from_host or "(unknown)"));
235 if session.type == "s2sin_unauthed" then 238 if session.type == "s2sin_unauthed" then
236 print(" Connection not yet authenticated"); 239 print(" Connection not yet authenticated");
237 end 240 end
238 for name in pairs(session.hosts) do 241 for name in pairs(session.hosts) do
239 if name ~= session.from_host then 242 if name ~= session.from_host then
240 print(" also hosts "..tostring(name)); 243 print(" also hosts "..tostring(name));
241 end 244 end
242 end 245 end
243 end 246 end
244 end 247 end
248
245 print = _print; 249 print = _print;
246 end 250 end
251
247 for session in pairs(incoming_s2s) do 252 for session in pairs(incoming_s2s) do
248 if not session.to_host then 253 if not session.to_host and ((not match_jid) or session.from_host and session.from_host:match(match_jid)) then
249 print("Other incoming s2s connections"); 254 print("Other incoming s2s connections");
250 print(" (unknown) <- "..(session.from_host or "(unknown)")); 255 print(" (unknown) <- "..(session.from_host or "(unknown)"));
251 end 256 end
252 end 257 end
253 end 258 end

mercurial