Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 6173:1600438c0c14
mod_admin_telnet: Move generation of log tag for s2s:show() (adds it to c2s:show() too)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 11 May 2014 19:12:03 +0200 |
parent | 6172:0205b97bb355 |
child | 6174:513ea94761b2 |
comparison
equal
deleted
inserted
replaced
6172:0205b97bb355 | 6173:1600438c0c14 |
---|---|
489 end | 489 end |
490 | 490 |
491 function def_env.hosts:add(name) | 491 function def_env.hosts:add(name) |
492 end | 492 end |
493 | 493 |
494 local function common_info(session, line) | |
495 if session.id then | |
496 line[#line+1] = "["..session.id.."]" | |
497 else | |
498 line[#line+1] = "["..session.type..(tostring(session):match("%x*$")).."]" | |
499 end | |
500 end | |
501 | |
494 local function session_flags(session, line) | 502 local function session_flags(session, line) |
495 line = line or {}; | 503 line = line or {}; |
504 common_info(session, line); | |
496 if session.type == "c2s" then | 505 if session.type == "c2s" then |
497 local status, priority = "unavailable", tostring(session.priority or "-"); | 506 local status, priority = "unavailable", tostring(session.priority or "-"); |
498 if session.presence then | 507 if session.presence then |
499 status = session.presence:get_child_text("show") or "available"; | 508 status = session.presence:get_child_text("show") or "available"; |
500 end | 509 end |
518 return table.concat(line, " "); | 527 return table.concat(line, " "); |
519 end | 528 end |
520 | 529 |
521 local function tls_info(session, line) | 530 local function tls_info(session, line) |
522 line = line or {}; | 531 line = line or {}; |
532 common_info(session, line); | |
523 if session.secure then | 533 if session.secure then |
524 local sock = session.conn and session.conn.socket and session.conn:socket(); | 534 local sock = session.conn and session.conn.socket and session.conn:socket(); |
525 if sock and sock.info then | 535 if sock and sock.info then |
526 local info = sock:info(); | 536 local info = sock:info(); |
527 line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher); | 537 line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher); |
626 direction = "<-"; | 636 direction = "<-"; |
627 count_in = count_in + 1; | 637 count_in = count_in + 1; |
628 remotehost, localhost = session.from_host or "?", session.to_host or "?"; | 638 remotehost, localhost = session.from_host or "?", session.to_host or "?"; |
629 end | 639 end |
630 local sess_lines = { l = localhost, r = remotehost, | 640 local sess_lines = { l = localhost, r = remotehost, |
631 annotate(session, { "", direction, remotehost or "?", | 641 annotate(session, { "", direction, remotehost or "?" })}; |
632 "["..session.type..tostring(session):match("[a-f0-9]*$").."]" })}; | |
633 | 642 |
634 if (not match_jid) or remotehost:match(match_jid) or localhost:match(match_jid) then | 643 if (not match_jid) or remotehost:match(match_jid) or localhost:match(match_jid) then |
635 table.insert(s2s_list, sess_lines); | 644 table.insert(s2s_list, sess_lines); |
636 local print = function (s) table.insert(sess_lines, " "..s); end | 645 local print = function (s) table.insert(sess_lines, " "..s); end |
637 if session.sendq then | 646 if session.sendq then |