Changeset

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
parents 10083:f30d505e755b
children 10085:bf51a08a94a7
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Fri Jul 26 20:25:15 2019 +0200
+++ b/plugins/mod_admin_telnet.lua	Fri Jul 26 21:05:13 2019 +0200
@@ -592,12 +592,16 @@
 	return jid_join("["..ip.."]:"..clientport, session.host or "["..serverip.."]:"..serverport);
 end
 
-local function show_c2s(callback)
+local function get_c2s()
 	local c2s = array.collect(values(prosody.full_sessions));
 	c2s:append(array.collect(values(module:shared"/*/c2s/sessions")));
 	c2s:append(array.collect(values(module:shared"/*/bosh/sessions")));
 	c2s:unique();
-	c2s:sort(function(a, b)
+	return c2s;
+end
+
+local function show_c2s(callback)
+	get_c2s():sort(function(a, b)
 		if a.host == b.host then
 			if a.username == b.username then
 				return (a.resource or "") > (b.resource or "");