Software /
code /
prosody-modules
Changeset
1117:d643c385d3f6
mod_admin_web: Provide some information about the TLS layer
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Mon, 22 Jul 2013 23:23:02 +0200 |
parents | 1116:2345a30dd8b4 |
children | 1118:e5441d46d6ff |
files | mod_admin_web/admin_web/mod_admin_web.lua mod_admin_web/admin_web/www_files/css/style.css mod_admin_web/admin_web/www_files/js/main.js |
diffstat | 3 files changed, 54 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_admin_web/admin_web/mod_admin_web.lua Sat Jul 13 17:43:30 2013 +0200 +++ b/mod_admin_web/admin_web/mod_admin_web.lua Mon Jul 22 23:23:02 2013 +0200 @@ -42,7 +42,12 @@ end local item = st.stanza("item", { id = id }):tag("session", {xmlns = xmlns_c2s_session, jid = name}):up(); if session.secure then - item:tag("encrypted"):up(); + local encrypted = item:tag("encrypted"); + local sock = session.conn and session.conn.socket and session.conn:socket() + local info = sock and sock.info and sock:info(); + for k, v in pairs(info or {}) do + encrypted:tag("info", { name = k }):text(tostring(v)):up(); + end end if session.compressed then item:tag("compressed"):up(); @@ -70,10 +75,19 @@ local item = st.stanza("item", { id = id }):tag("session", {xmlns = xmlns_s2s_session, jid = name}) :tag(type):up(); if session.secure then + local encrypted = item:tag("encrypted"); + + local sock = session.conn and session.conn.socket and session.conn:socket() + local info = sock and sock.info and sock:info(); + for k, v in pairs(info or {}) do + encrypted:tag("info", { name = k }):text(tostring(v)):up(); + end + local sock = session.conn:socket() + if session.cert_identity_status == "valid" then - item:tag("encrypted"):tag("valid"):up():up(); + encrypted:tag("valid"); else - item:tag("encrypted"):tag("invalid"):up():up(); + encrypted:tag("invalid"); end end if session.compressed then
--- a/mod_admin_web/admin_web/www_files/css/style.css Sat Jul 13 17:43:30 2013 +0200 +++ b/mod_admin_web/admin_web/www_files/css/style.css Mon Jul 22 23:23:02 2013 +0200 @@ -6,7 +6,7 @@ color: #0000FF } -ul { +#adhocCommands > ul { margin: 0 }
--- a/mod_admin_web/admin_web/www_files/js/main.js Sat Jul 13 17:43:30 2013 +0200 +++ b/mod_admin_web/admin_web/www_files/js/main.js Mon Jul 22 23:23:02 2013 +0200 @@ -26,23 +26,36 @@ } function _cbNewS2S(e) { - var items, entry, tmp, retract, id, jid; + var items, item, entry, tmp, retract, id, jid, infos, info, metadata; items = e.getElementsByTagName('item'); for (i = 0; i < items.length; i++) { - id = items[i].attributes.getNamedItem('id').value; - jid = items[i].getElementsByTagName('session')[0].attributes.getNamedItem('jid').value; + item = items[i]; + id = item.attributes.getNamedItem('id').value; + jid = item.getElementsByTagName('session')[0].attributes.getNamedItem('jid').value; + infos = item.getElementsByTagName('info'); entry = $('<li id="' + id + '">' + jid + '</li>'); - if (tmp = items[i].getElementsByTagName('encrypted')[0]) { + if (tmp = item.getElementsByTagName('encrypted')[0]) { if (tmp.getElementsByTagName('valid')[0]) { entry.append('<img src="images/secure.png" title="encrypted (certificate valid)" alt=" (secure) (encrypted)" />'); } else { entry.append('<img src="images/encrypted.png" title="encrypted (certificate invalid)" alt=" (encrypted)" />'); } } - if (items[i].getElementsByTagName('compressed')[0]) { + if (item.getElementsByTagName('compressed')[0]) { entry.append('<img src="images/compressed.png" title="compressed" alt=" (compressed)" />'); } + metadata = $('<ul/>').css('display', 'none'); + entry.on('click', function() { + $(this).find("ul").slideToggle(); + }); + metadata.appendTo(entry); + for (j = 0; j < infos.length; j++) { + info = infos[j]; + metadata.append('<li><b>' + info.attributes.getNamedItem('name').value + ':</b> ' + info.innerHTML + '</li>'); + } + if (infos.length == 0) + metadata.append('<li>No information available</li>'); if (items[i].getElementsByTagName('out')[0]) { entry.appendTo('#s2sout'); @@ -59,18 +72,31 @@ } function _cbNewC2S(e) { - var items, entry, retract, id, jid; + var items, item, entry, retract, id, jid, infos, info, metadata; items = e.getElementsByTagName('item'); for (i = 0; i < items.length; i++) { - id = items[i].attributes.getNamedItem('id').value; - jid = items[i].getElementsByTagName('session')[0].attributes.getNamedItem('jid').value; + item = items[i]; + id = item.attributes.getNamedItem('id').value; + jid = item.getElementsByTagName('session')[0].attributes.getNamedItem('jid').value; + infos = item.getElementsByTagName('info'); entry = $('<li id="' + id + '">' + jid + '</li>'); - if (items[i].getElementsByTagName('encrypted')[0]) { + if (item.getElementsByTagName('encrypted')[0]) { entry.append('<img src="images/encrypted.png" title="encrypted" alt=" (encrypted)" />'); } - if (items[i].getElementsByTagName('compressed')[0]) { + if (item.getElementsByTagName('compressed')[0]) { entry.append('<img src="images/compressed.png" title="compressed" alt=" (compressed)" />'); } + metadata = $('<ul/>').css('display', 'none'); + entry.on('click', function() { + $(this).find("ul").slideToggle(); + }); + metadata.appendTo(entry); + for (j = 0; j < infos.length; j++) { + info = infos[j]; + metadata.append('<li><b>' + info.attributes.getNamedItem('name').value + ':</b> ' + info.innerHTML + '</li>'); + } + if (infos.length == 0) + metadata.append('<li>No information available</li>'); entry.appendTo('#c2s'); } retract = e.getElementsByTagName('retract')[0];