Software /
code /
prosody
Changeset
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 |
parents | 10469:658b759a1f7a |
children | 10471:ae906d51e3d2 |
files | plugins/mod_admin_telnet.lua |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
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