Software / code / prosody
Comparison
plugins/mod_admin_shell.lua @ 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 |
| parent | 13053:8128c4f1b08b |
| child | 13062:da51c36ed1e7 |
comparison
equal
deleted
inserted
replaced
| 13060:8dd5d247f989 | 13061:7e0bb5154f3b |
|---|---|
| 1098 local columns = get_colspec(colspec, { "id"; "host"; "dir"; "remote"; "ipv"; "secure"; "s2s_sasl"; "dialback" }); | 1098 local columns = get_colspec(colspec, { "id"; "host"; "dir"; "remote"; "ipv"; "secure"; "s2s_sasl"; "dialback" }); |
| 1099 local row = format_table(columns, self.session.width); | 1099 local row = format_table(columns, self.session.width); |
| 1100 | 1100 |
| 1101 local function match(session) | 1101 local function match(session) |
| 1102 local host, remote = get_s2s_hosts(session); | 1102 local host, remote = get_s2s_hosts(session); |
| 1103 return not match_jid or match_jid == "*" or host == match_jid or remote == match_jid; | 1103 if not match_jid or match_jid == "*" then |
| 1104 return true; | |
| 1105 elseif host == match_jid or remote == match_jid then | |
| 1106 return true; | |
| 1107 elseif match_jid:sub(1, 2) == "*." then | |
| 1108 -- (host) == *.(host) or sub(.host) == *(.host) | |
| 1109 if host == match_jid:sub(3) or host:sub(-#match_jid + 1) == match_jid:sub(2) then | |
| 1110 return true | |
| 1111 elseif remote == match_jid:sub(3) or remote:sub(-#match_jid + 1) == match_jid:sub(2) then | |
| 1112 return true | |
| 1113 end | |
| 1114 end | |
| 1115 return false; | |
| 1104 end | 1116 end |
| 1105 | 1117 |
| 1106 local group_by_host = true; | 1118 local group_by_host = true; |
| 1107 local currenthost = nil; | 1119 local currenthost = nil; |
| 1108 for _, col in ipairs(columns) do | 1120 for _, col in ipairs(columns) do |