Comparison

plugins/mod_admin_telnet.lua @ 4514:ae48e0abc233

mod_admin_telnet: Commond and flexible way to show stream properties.
author Kim Alvefur <zash@zash.se>
date Mon, 05 Mar 2012 22:07:40 +0100
parent 4328:c71777a8b9c7
child 4515:e2774644688d
comparison
equal deleted inserted replaced
4513:23b540ab346a 4514:ae48e0abc233
485 end 485 end
486 end); 486 end);
487 return true, "Total: "..count.." sessions closed"; 487 return true, "Total: "..count.." sessions closed";
488 end 488 end
489 489
490 local function session_flags(session, line)
491 if session.cert_identity_status == "valid" then
492 line[#line+1] = "(secure)";
493 end
494 if session.secure then
495 line[#line+1] = "(encrypted)";
496 end
497 if session.compressed then
498 line[#line+1] = "(compressed)";
499 end
500 return table.concat(line, " ");
501 end
502
490 def_env.s2s = {}; 503 def_env.s2s = {};
491 function def_env.s2s:show(match_jid) 504 function def_env.s2s:show(match_jid)
492 local _print = self.session.print; 505 local _print = self.session.print;
493 local print = self.session.print; 506 local print = self.session.print;
494 507
497 for host, host_session in pairs(hosts) do 510 for host, host_session in pairs(hosts) do
498 print = function (...) _print(host); _print(...); print = _print; end 511 print = function (...) _print(host); _print(...); print = _print; end
499 for remotehost, session in pairs(host_session.s2sout) do 512 for remotehost, session in pairs(host_session.s2sout) do
500 if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then 513 if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then
501 count_out = count_out + 1; 514 count_out = count_out + 1;
502 print(" "..host.." -> "..remotehost..(session.cert_identity_status == "valid" and " (secure)" or "")..(session.secure and " (encrypted)" or "")..(session.compressed and " (compressed)" or "")); 515 print(session_flags(session, {" ", host, "->", remotehost}));
503 if session.sendq then 516 if session.sendq then
504 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); 517 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection");
505 end 518 end
506 if session.type == "s2sout_unauthed" then 519 if session.type == "s2sout_unauthed" then
507 if session.connecting then 520 if session.connecting then
534 if session.to_host == host and ((not match_jid) or host:match(match_jid) 547 if session.to_host == host and ((not match_jid) or host:match(match_jid)
535 or (session.from_host and session.from_host:match(match_jid)) 548 or (session.from_host and session.from_host:match(match_jid))
536 -- Pft! is what I say to list comprehensions 549 -- Pft! is what I say to list comprehensions
537 or (session.hosts and #array.collect(keys(session.hosts)):filter(subhost_filter)>0)) then 550 or (session.hosts and #array.collect(keys(session.hosts)):filter(subhost_filter)>0)) then
538 count_in = count_in + 1; 551 count_in = count_in + 1;
539 print(" "..host.." <- "..(session.from_host or "(unknown)")..(session.cert_identity_status == "valid" and " (secure)" or "")..(session.secure and " (encrypted)" or "")..(session.compressed and " (compressed)" or "")); 552 print(session_flags(session, {" ", host, "<-", session.from_host or "(unknown)"}));
540 if session.type == "s2sin_unauthed" then 553 if session.type == "s2sin_unauthed" then
541 print(" Connection not yet authenticated"); 554 print(" Connection not yet authenticated");
542 end 555 end
543 for name in pairs(session.hosts) do 556 for name in pairs(session.hosts) do
544 if name ~= session.from_host then 557 if name ~= session.from_host then