Comparison

plugins/mod_admin_telnet.lua @ 4518:f2d695d2e31e

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Fri, 09 Mar 2012 18:46:19 +0000
parent 4517:2e274e088ddc
child 4684:dc70c4ffb66d
comparison
equal deleted inserted replaced
4512:eb97612bf42b 4518:f2d695d2e31e
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 elseif session.secure then
494 line[#line+1] = "(encrypted)";
495 end
496 if session.compressed then
497 line[#line+1] = "(compressed)";
498 end
499 if session.smacks then
500 line[#line+1] = "(sm)";
501 end
502 if session.conn and session.conn:ip():match(":") then
503 line[#line+1] = "(IPv6)";
504 end
505 return table.concat(line, " ");
506 end
507
490 def_env.s2s = {}; 508 def_env.s2s = {};
491 function def_env.s2s:show(match_jid) 509 function def_env.s2s:show(match_jid)
492 local _print = self.session.print; 510 local _print = self.session.print;
493 local print = self.session.print; 511 local print = self.session.print;
494 512
497 for host, host_session in pairs(hosts) do 515 for host, host_session in pairs(hosts) do
498 print = function (...) _print(host); _print(...); print = _print; end 516 print = function (...) _print(host); _print(...); print = _print; end
499 for remotehost, session in pairs(host_session.s2sout) do 517 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 518 if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then
501 count_out = count_out + 1; 519 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 "")); 520 print(session_flags(session, {" ", host, "->", remotehost}));
503 if session.sendq then 521 if session.sendq then
504 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); 522 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection");
505 end 523 end
506 if session.type == "s2sout_unauthed" then 524 if session.type == "s2sout_unauthed" then
507 if session.connecting then 525 if session.connecting then
534 if session.to_host == host and ((not match_jid) or host:match(match_jid) 552 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)) 553 or (session.from_host and session.from_host:match(match_jid))
536 -- Pft! is what I say to list comprehensions 554 -- Pft! is what I say to list comprehensions
537 or (session.hosts and #array.collect(keys(session.hosts)):filter(subhost_filter)>0)) then 555 or (session.hosts and #array.collect(keys(session.hosts)):filter(subhost_filter)>0)) then
538 count_in = count_in + 1; 556 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 "")); 557 print(session_flags(session, {" ", host, "<-", session.from_host or "(unknown)"}));
540 if session.type == "s2sin_unauthed" then 558 if session.type == "s2sin_unauthed" then
541 print(" Connection not yet authenticated"); 559 print(" Connection not yet authenticated");
542 end 560 end
543 for name in pairs(session.hosts) do 561 for name in pairs(session.hosts) do
544 if name ~= session.from_host then 562 if name ~= session.from_host then