Software /
code /
prosody
Changeset
12537:74418f8096b0
mod_admin_shell: Show bound ports in module:info
I.e. the subset of port:list() relevant to the specified module.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 31 May 2022 00:31:56 +0200 |
parents | 12536:a8cb1d7a98db |
children | 12538:0f56587bb37f |
files | plugins/mod_admin_shell.lua |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua Mon May 30 14:54:10 2022 +0200 +++ b/plugins/mod_admin_shell.lua Tue May 31 00:31:56 2022 +0200 @@ -513,7 +513,17 @@ ["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));