Comparison

plugins/mod_admin_shell.lua @ 13488:b2b090181270 0.12

mod_admin_shell: Allow matching on host or bare JID in c2s:show Only supporting exact match on full JID isn't helpful if you want to list sessions per host or user. Backport of 430333198e4c Fixes #1857
author Kim Alvefur <zash@zash.se>
date Fri, 31 Mar 2023 22:01:27 +0200
parent 13077:de42a93a7c8d
child 13489:ae65f199f408
comparison
equal deleted inserted replaced
13487:84fa880bf476 13488:b2b090181270
23 local prosody = _G.prosody; 23 local prosody = _G.prosody;
24 24
25 local unpack = table.unpack or unpack; -- luacheck: ignore 113 25 local unpack = table.unpack or unpack; -- luacheck: ignore 113
26 local iterators = require "util.iterators"; 26 local iterators = require "util.iterators";
27 local keys, values = iterators.keys, iterators.values; 27 local keys, values = iterators.keys, iterators.values;
28 local jid_bare, jid_split, jid_join = import("util.jid", "bare", "prepped_split", "join"); 28 local jid_bare, jid_split, jid_join, jid_compare = import("util.jid", "bare", "prepped_split", "join", "compare");
29 local set, array = require "util.set", require "util.array"; 29 local set, array = require "util.set", require "util.array";
30 local cert_verify_identity = require "util.x509".verify_identity; 30 local cert_verify_identity = require "util.x509".verify_identity;
31 local envload = require "util.envload".envload; 31 local envload = require "util.envload".envload;
32 local envloadfile = require "util.envload".envloadfile; 32 local envloadfile = require "util.envload".envloadfile;
33 local has_pposix, pposix = pcall(require, "util.pposix"); 33 local has_pposix, pposix = pcall(require, "util.pposix");
938 local columns = get_colspec(colspec, { "id"; "jid"; "ipv"; "status"; "secure"; "smacks"; "csi" }); 938 local columns = get_colspec(colspec, { "id"; "jid"; "ipv"; "status"; "secure"; "smacks"; "csi" });
939 local row = format_table(columns, 120); 939 local row = format_table(columns, 120);
940 940
941 local function match(session) 941 local function match(session)
942 local jid = get_jid(session) 942 local jid = get_jid(session)
943 return (not match_jid) or jid == match_jid; 943 return (not match_jid) or jid_compare(jid, match_jid);
944 end 944 end
945 945
946 local group_by_host = true; 946 local group_by_host = true;
947 for _, col in ipairs(columns) do 947 for _, col in ipairs(columns) do
948 if col.key == "full_jid" or col.key == "host" then 948 if col.key == "full_jid" or col.key == "host" then