Software /
code /
prosody-modules
Comparison
mod_telnet_tlsinfo/mod_telnet_tlsinfo.lua @ 1087:447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 27 Jun 2013 18:22:53 +0200 |
child | 1132:832235cc1910 |
comparison
equal
deleted
inserted
replaced
1086:50ee38e95e75 | 1087:447af80a16ad |
---|---|
1 -- mod_telnet_tlsinfo.lua | |
2 | |
3 module:set_global(); | |
4 module:depends("admin_telnet"); | |
5 | |
6 local console_env = module:shared("/*/admin_telnet/env"); | |
7 local c2s_sessions = module:shared("/*/c2s/sessions"); | |
8 local s2s_sessions = module:shared("/*/s2s/sessions"); | |
9 | |
10 local function print_tlsinfo(print, session) | |
11 if session.secure then | |
12 local sock = session.conn:socket() | |
13 for k,v in pairs(sock:info()) do | |
14 print(("%20s: %s"):format(k, tostring(v))) | |
15 end | |
16 else | |
17 print(("%20s: %s"):format("protocol", "TCP")) | |
18 end | |
19 end | |
20 | |
21 function console_env.c2s:showtls() | |
22 local print = self.session.print; | |
23 for _, session in pairs(c2s_sessions) do | |
24 print(session.full_jid or "unauthenticated") | |
25 print_tlsinfo(print, session); | |
26 print"" | |
27 end | |
28 end | |
29 | |
30 function console_env.s2s:showtls() | |
31 local print = self.session.print; | |
32 for _, session in pairs(s2s_sessions) do | |
33 if session.direction == "outgoing" then | |
34 print(session.from_host, "->", session.to_host) | |
35 else | |
36 print(session.to_host, "<-", session.from_host) | |
37 end | |
38 print_tlsinfo(print, session); | |
39 print"" | |
40 end | |
41 end |