aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-04-08 10:16:18 +0200
committerKim Alvefur <zash@zash.se>2023-04-08 10:16:18 +0200
commit9f691e9796634784f459bc0dbbc35dad83b104c3 (patch)
treee18b8ab11afd74be29e69790ced8726feb04483f /plugins
parent323408cfc9bd2d685d10372fed2fa903ec7f7125 (diff)
downloadprosody-9f691e9796634784f459bc0dbbc35dad83b104c3.tar.gz
prosody-9f691e9796634784f459bc0dbbc35dad83b104c3.zip
mod_admin_shell: Allow wildcard matches like s2s:show("*.example.com")
E.g. if you want to show connections to/from a domain, including its subdomains, this is handy.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_admin_shell.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index 15a41b55..12fe2031 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -1100,7 +1100,19 @@ function def_env.s2s:show(match_jid, colspec)
local function match(session)
local host, remote = get_s2s_hosts(session);
- return not match_jid or match_jid == "*" or host == match_jid or remote == match_jid;
+ if not match_jid or match_jid == "*" then
+ return true;
+ elseif host == match_jid or remote == match_jid then
+ return true;
+ elseif match_jid:sub(1, 2) == "*." then
+ -- (host) == *.(host) or sub(.host) == *(.host)
+ if host == match_jid:sub(3) or host:sub(-#match_jid + 1) == match_jid:sub(2) then
+ return true
+ elseif remote == match_jid:sub(3) or remote:sub(-#match_jid + 1) == match_jid:sub(2) then
+ return true
+ end
+ end
+ return false;
end
local group_by_host = true;