diff options
author | Kim Alvefur <zash@zash.se> | 2019-12-15 21:42:42 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-12-15 21:42:42 +0100 |
commit | d146d6b8acb261c4a2e1f6d721fdd44243805fd3 (patch) | |
tree | 5037a3953d82a623332f287a2eb48cca66951932 /plugins | |
parent | d0cd5469d272364bede91196edbb783e3fe1f769 (diff) | |
download | prosody-d146d6b8acb261c4a2e1f6d721fdd44243805fd3.tar.gz prosody-d146d6b8acb261c4a2e1f6d721fdd44243805fd3.zip |
mod_admin_telnet: Merge hostname comparison functions
Missed that there existed one already when writing the one for host:list
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_telnet.lua | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 6dc7c5c3..6ed36258 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -433,7 +433,7 @@ end 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 @@ function def_env.host:deactivate(hostname, reason) 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 |