Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 5586:7e1264bf7af8
mod_admin_telnet: List session flags (encryption, compression etc) the same way for c2s as s2s
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 17 May 2013 14:56:06 +0200 |
parent | 5579:e449e6342e36 |
child | 5593:98a485212592 |
comparison
equal
deleted
inserted
replaced
5585:3e097acf82de | 5586:7e1264bf7af8 |
---|---|
482 end | 482 end |
483 | 483 |
484 function def_env.hosts:add(name) | 484 function def_env.hosts:add(name) |
485 end | 485 end |
486 | 486 |
487 local function session_flags(session, line) | |
488 line = line or {}; | |
489 if session.cert_identity_status == "valid" then | |
490 line[#line+1] = "(secure)"; | |
491 elseif session.secure then | |
492 line[#line+1] = "(encrypted)"; | |
493 end | |
494 if session.compressed then | |
495 line[#line+1] = "(compressed)"; | |
496 end | |
497 if session.smacks then | |
498 line[#line+1] = "(sm)"; | |
499 end | |
500 if (session.ip or session.conn and session.conn:ip()):match(":") then | |
501 line[#line+1] = "(IPv6)"; | |
502 end | |
503 return table.concat(line, " "); | |
504 end | |
505 | |
487 def_env.c2s = {}; | 506 def_env.c2s = {}; |
488 | 507 |
489 local function show_c2s(callback) | 508 local function show_c2s(callback) |
490 for hostname, host in pairs(hosts) do | 509 for hostname, host in pairs(hosts) do |
491 for username, user in pairs(host.sessions or {}) do | 510 for username, user in pairs(host.sessions or {}) do |
524 status = status:get_text() or "[invalid!]"; | 543 status = status:get_text() or "[invalid!]"; |
525 else | 544 else |
526 status = "available"; | 545 status = "available"; |
527 end | 546 end |
528 end | 547 end |
529 print(" "..jid.." - "..status.."("..priority..")"); | 548 print(session_flags(session, { " "..jid.." - "..status.."("..priority..")" })); |
530 end | 549 end |
531 end); | 550 end); |
532 return true, "Total: "..count.." clients"; | 551 return true, "Total: "..count.." clients"; |
533 end | 552 end |
534 | 553 |
563 end | 582 end |
564 end); | 583 end); |
565 return true, "Total: "..count.." sessions closed"; | 584 return true, "Total: "..count.." sessions closed"; |
566 end | 585 end |
567 | 586 |
568 local function session_flags(session, line) | |
569 if session.cert_identity_status == "valid" then | |
570 line[#line+1] = "(secure)"; | |
571 elseif session.secure then | |
572 line[#line+1] = "(encrypted)"; | |
573 end | |
574 if session.compressed then | |
575 line[#line+1] = "(compressed)"; | |
576 end | |
577 if session.smacks then | |
578 line[#line+1] = "(sm)"; | |
579 end | |
580 if session.conn and session.conn:ip():match(":") then | |
581 line[#line+1] = "(IPv6)"; | |
582 end | |
583 return table.concat(line, " "); | |
584 end | |
585 | 587 |
586 def_env.s2s = {}; | 588 def_env.s2s = {}; |
587 function def_env.s2s:show(match_jid) | 589 function def_env.s2s:show(match_jid) |
588 local _print = self.session.print; | 590 local _print = self.session.print; |
589 local print = self.session.print; | 591 local print = self.session.print; |