Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 10084:e4043e3928f2
mod_admin_telnet: Factor out function for collecting all c2s sessions for easier reuse
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 26 Jul 2019 21:05:13 +0200 |
parent | 10083:f30d505e755b |
child | 10085:bf51a08a94a7 |
comparison
equal
deleted
inserted
replaced
10083:f30d505e755b | 10084:e4043e3928f2 |
---|---|
590 local serverip = conn and conn.server and conn:server():ip() or "?"; | 590 local serverip = conn and conn.server and conn:server():ip() or "?"; |
591 local serverport = conn and conn:serverport() or "?" | 591 local serverport = conn and conn:serverport() or "?" |
592 return jid_join("["..ip.."]:"..clientport, session.host or "["..serverip.."]:"..serverport); | 592 return jid_join("["..ip.."]:"..clientport, session.host or "["..serverip.."]:"..serverport); |
593 end | 593 end |
594 | 594 |
595 local function show_c2s(callback) | 595 local function get_c2s() |
596 local c2s = array.collect(values(prosody.full_sessions)); | 596 local c2s = array.collect(values(prosody.full_sessions)); |
597 c2s:append(array.collect(values(module:shared"/*/c2s/sessions"))); | 597 c2s:append(array.collect(values(module:shared"/*/c2s/sessions"))); |
598 c2s:append(array.collect(values(module:shared"/*/bosh/sessions"))); | 598 c2s:append(array.collect(values(module:shared"/*/bosh/sessions"))); |
599 c2s:unique(); | 599 c2s:unique(); |
600 c2s:sort(function(a, b) | 600 return c2s; |
601 end | |
602 | |
603 local function show_c2s(callback) | |
604 get_c2s():sort(function(a, b) | |
601 if a.host == b.host then | 605 if a.host == b.host then |
602 if a.username == b.username then | 606 if a.username == b.username then |
603 return (a.resource or "") > (b.resource or ""); | 607 return (a.resource or "") > (b.resource or ""); |
604 end | 608 end |
605 return (a.username or "") > (b.username or ""); | 609 return (a.username or "") > (b.username or ""); |