aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-09-21 14:36:29 +0100
committerMatthew Wild <mwild1@gmail.com>2018-09-21 14:36:29 +0100
commitcceeea2c2864e8617b987a90985108bbdf3fe1b3 (patch)
tree71c64a41d8f380cb9b3f5ede85d8b036933f1081 /plugins
parentd338d4b82ca2098c365f3fa7a4c568e222fe9b7a (diff)
downloadprosody-cceeea2c2864e8617b987a90985108bbdf3fe1b3.tar.gz
prosody-cceeea2c2864e8617b987a90985108bbdf3fe1b3.zip
mod_admin_telnet: Make use of util.iterators.sorted_pairs()
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_admin_telnet.lua17
1 files changed, 7 insertions, 10 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index 17351787..363a5c9b 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -875,9 +875,9 @@ function def_env.host:list()
local print = self.session.print;
local i = 0;
local type;
- for host in values(array.collect(keys(prosody.hosts)):sort()) do
+ for host, host_session in it.sorted_pairs(prosody.hosts) do
i = i + 1;
- type = hosts[host].type;
+ type = host_session.type;
if type == "local" then
print(host);
else
@@ -896,14 +896,11 @@ def_env.port = {};
function def_env.port:list()
local print = self.session.print;
local services = portmanager.get_active_services().data;
- local ordered_services, n_ports = {}, 0;
- for service, interfaces in pairs(services) do
- table.insert(ordered_services, service);
- end
- table.sort(ordered_services);
- for _, service in ipairs(ordered_services) do
+ local n_services, n_ports = 0, 0;
+ for service, interfaces in it.sorted_pairs(services) do
+ n_services = n_services + 1;
local ports_list = {};
- for interface, ports in pairs(services[service]) do
+ for interface, ports in pairs(interfaces) do
for port in pairs(ports) do
table.insert(ports_list, "["..interface.."]:"..port);
end
@@ -911,7 +908,7 @@ function def_env.port:list()
n_ports = n_ports + #ports_list;
print(service..": "..table.concat(ports_list, ", "));
end
- return true, #ordered_services.." services listening on "..n_ports.." ports";
+ return true, n_services.." services listening on "..n_ports.." ports";
end
function def_env.port:close(close_port, close_interface)