aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-05-31 00:31:56 +0200
committerKim Alvefur <zash@zash.se>2022-05-31 00:31:56 +0200
commitb7bd70874a1dd468bc9acdffeebe9b240ba9d04f (patch)
tree21562724e5c3813061f3471c2ec6cb09b70b7fd9
parent8ba6d3a2b1e2eb5dee1ceb25bde0f799fb4b793c (diff)
downloadprosody-b7bd70874a1dd468bc9acdffeebe9b240ba9d04f.tar.gz
prosody-b7bd70874a1dd468bc9acdffeebe9b240ba9d04f.zip
mod_admin_shell: Show bound ports in module:info
I.e. the subset of port:list() relevant to the specified module.
-rw-r--r--plugins/mod_admin_shell.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index ca9cb0d5..1ced2e49 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -513,7 +513,17 @@ function def_env.module:info(name, hosts)
["auth-provider"] = item_name,
["storage-provider"] = item_name,
["http-provider"] = function(item, mod) return mod:http_url(item.name, item.default_path); end,
- ["net-provider"] = item_name,
+ ["net-provider"] = function(item, mod)
+ local service_name = item.name;
+ local ports_list = {};
+ for _, interface, port in portmanager.get_active_services():iter(service_name, nil, nil) do
+ table.insert(ports_list, "["..interface.."]:"..port);
+ end
+ if not ports_list[1] then
+ return service_name..": not listening on any ports";
+ end
+ return service_name..": "..table.concat(ports_list, ", ");
+ end,
["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end,
["metric"] = function(item)
return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description));