Comparison

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
comparison
equal deleted inserted replaced
10469:658b759a1f7a 10470:5267f12b038d
962 end 962 end
963 function def_env.host:deactivate(hostname, reason) 963 function def_env.host:deactivate(hostname, reason)
964 return hostmanager.deactivate(hostname, reason); 964 return hostmanager.deactivate(hostname, reason);
965 end 965 end
966 966
967 local function compare_hosts(a, b)
968 return a:gsub("%P", string.reverse):reverse() < b:gsub("%P", string.reverse):reverse();
969 end
970
967 function def_env.host:list() 971 function def_env.host:list()
968 local print = self.session.print; 972 local print = self.session.print;
969 local i = 0; 973 local i = 0;
970 local type; 974 local type;
971 for host, host_session in iterators.sorted_pairs(prosody.hosts) do 975 for host, host_session in iterators.sorted_pairs(prosody.hosts, compare_hosts) do
972 i = i + 1; 976 i = i + 1;
973 type = host_session.type; 977 type = host_session.type;
974 if type == "local" then 978 if type == "local" then
975 print(host); 979 print(host);
976 else 980 else