Diff

plugins/mod_admin_telnet.lua @ 10470:5267f12b038d

mod_admin_telnet: Sort hosts Groups by domain in DNS hierarchy order or something. Why not split on '.' you ask? Well becasue that's not what I typed here. Also "[^.]" is longer than "%P".
author Kim Alvefur <zash@zash.se>
date Sat, 30 Nov 2019 21:56:21 +0100
parent 10461:e293fb8112e2
child 10489:fabe50ea39f2
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Sat Nov 30 19:34:40 2019 +0100
+++ b/plugins/mod_admin_telnet.lua	Sat Nov 30 21:56:21 2019 +0100
@@ -964,11 +964,15 @@
 	return hostmanager.deactivate(hostname, reason);
 end
 
+local function compare_hosts(a, b)
+	return a:gsub("%P", string.reverse):reverse() < b:gsub("%P", string.reverse):reverse();
+end
+
 function def_env.host:list()
 	local print = self.session.print;
 	local i = 0;
 	local type;
-	for host, host_session in iterators.sorted_pairs(prosody.hosts) do
+	for host, host_session in iterators.sorted_pairs(prosody.hosts, compare_hosts) do
 		i = i + 1;
 		type = host_session.type;
 		if type == "local" then