Changeset

10506:af214e2739f5

mod_admin_telnet: Merge hostname comparison functions Missed that there existed one already when writing the one for host:list
author Kim Alvefur <zash@zash.se>
date Sun, 15 Dec 2019 21:42:42 +0100
parents 10505:142bdba5eea2
children 10507:4d3549e64489
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Sun Dec 15 20:44:10 2019 +0100
+++ b/plugins/mod_admin_telnet.lua	Sun Dec 15 21:42:42 2019 +0100
@@ -433,7 +433,7 @@
 local function _sort_hosts(a, b)
 	if a == "*" then return true
 	elseif b == "*" then return false
-	else return a < b; end
+	else return a:gsub("[^.]+", string.reverse):reverse() < b:gsub("[^.]+", string.reverse):reverse(); end
 end
 
 function def_env.module:reload(name, hosts)
@@ -964,15 +964,11 @@
 	return hostmanager.deactivate(hostname, reason);
 end
 
-local function compare_hosts(a, b)
-	return a:gsub("[^.]+", string.reverse):reverse() < b:gsub("[^.]+", 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, compare_hosts) do
+	for host, host_session in iterators.sorted_pairs(prosody.hosts, _sort_hosts) do
 		i = i + 1;
 		type = host_session.type;
 		if type == "local" then