From 9f691e9796634784f459bc0dbbc35dad83b104c3 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 8 Apr 2023 10:16:18 +0200 Subject: 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. --- plugins/mod_admin_shell.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'plugins') 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; -- cgit v1.2.3