diff options
author | Kim Alvefur <zash@zash.se> | 2019-11-30 21:56:21 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-11-30 21:56:21 +0100 |
commit | 3d63c139e666e1a89f5caa0eb96afc20ac43fc2a (patch) | |
tree | e4de327aaa8dfcbfbc8aaca4d9624a6f2ef6bf47 /plugins | |
parent | c02ddf92ec53dd2c0473ef98427ceb4020d1f001 (diff) | |
download | prosody-3d63c139e666e1a89f5caa0eb96afc20ac43fc2a.tar.gz prosody-3d63c139e666e1a89f5caa0eb96afc20ac43fc2a.zip |
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".
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_telnet.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index f3ab9597..8427f811 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -964,11 +964,15 @@ function def_env.host:deactivate(hostname, reason) 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 |