Changeset

13061:7e0bb5154f3b

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.
author Kim Alvefur <zash@zash.se>
date Sat, 08 Apr 2023 10:16:18 +0200
parents 13060:8dd5d247f989
children 13062:da51c36ed1e7
files plugins/mod_admin_shell.lua
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Fri Apr 07 17:18:23 2023 +0200
+++ b/plugins/mod_admin_shell.lua	Sat Apr 08 10:16:18 2023 +0200
@@ -1100,7 +1100,19 @@
 
 	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;