Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 11917:d27b74b25105
mod_admin_shell: Return counts of shown vs total from new table views
Not exactly the way it was before, but close enough and useful.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 16 Nov 2021 16:06:41 +0100 |
parent | 11905:bbfa707a4756 |
child | 11930:ec46f110ce1d |
comparison
equal
deleted
inserted
replaced
11916:5dae9262f81f | 11917:d27b74b25105 |
---|---|
849 end | 849 end |
850 | 850 |
851 if not group_by_host then print(row()); end | 851 if not group_by_host then print(row()); end |
852 local currenthost = nil; | 852 local currenthost = nil; |
853 | 853 |
854 for _, session in ipairs(get_c2s():filter(match):sort(_sort_by_jid)) do | 854 local c2s_sessions = get_c2s(); |
855 local total_count = #c2s_sessions; | |
856 c2s_sessions:filter(match):sort(_sort_by_jid); | |
857 local shown_count = #c2s_sessions; | |
858 for _, session in ipairs(c2s_sessions) do | |
855 if group_by_host and session.host ~= currenthost then | 859 if group_by_host and session.host ~= currenthost then |
856 currenthost = session.host; | 860 currenthost = session.host; |
857 print("#",prosody.hosts[currenthost] or "Unknown host"); | 861 print("#",prosody.hosts[currenthost] or "Unknown host"); |
858 print(row()); | 862 print(row()); |
859 end | 863 end |
860 | 864 |
861 print(row(session)); | 865 print(row(session)); |
862 end | 866 end |
863 return true; | 867 if total_count ~= shown_count then |
868 return true, ("%d out of %d c2s sessions shown"):format(shown_count, total_count); | |
869 end | |
870 return true, ("%d c2s sessions shown"):format(total_count); | |
864 end | 871 end |
865 | 872 |
866 function def_env.c2s:show_tls(match_jid) | 873 function def_env.c2s:show_tls(match_jid) |
867 return self:show(match_jid, { "jid"; "id"; "secure"; "encryption" }); | 874 return self:show(match_jid, { "jid"; "id"; "secure"; "encryption" }); |
868 end | 875 end |
925 end | 932 end |
926 end | 933 end |
927 | 934 |
928 if not group_by_host then print(row()); end | 935 if not group_by_host then print(row()); end |
929 | 936 |
930 local s2s_sessions = array(iterators.values(module:shared"/*/s2s/sessions")):filter(match):sort(_sort_s2s); | 937 local s2s_sessions = array(iterators.values(module:shared"/*/s2s/sessions")); |
938 local total_count = #s2s_sessions; | |
939 s2s_sessions:filter(match):sort(_sort_s2s); | |
940 local shown_count = #s2s_sessions; | |
931 | 941 |
932 for _, session in ipairs(s2s_sessions) do | 942 for _, session in ipairs(s2s_sessions) do |
933 if group_by_host and currenthost ~= get_s2s_hosts(session) then | 943 if group_by_host and currenthost ~= get_s2s_hosts(session) then |
934 currenthost = get_s2s_hosts(session); | 944 currenthost = get_s2s_hosts(session); |
935 print("#",prosody.hosts[currenthost] or "Unknown host"); | 945 print("#",prosody.hosts[currenthost] or "Unknown host"); |
936 print(row()); | 946 print(row()); |
937 end | 947 end |
938 | 948 |
939 print(row(session)); | 949 print(row(session)); |
940 end | 950 end |
941 return true; -- TODO counts | 951 if total_count ~= shown_count then |
952 return true, ("%d out of %d s2s connections shown"):format(shown_count, total_count); | |
953 end | |
954 return true, ("%d s2s connections shown"):format(total_count); | |
942 end | 955 end |
943 | 956 |
944 function def_env.s2s:show_tls(match_jid) | 957 function def_env.s2s:show_tls(match_jid) |
945 return self:show(match_jid, { "id"; "host"; "dir"; "remote"; "secure"; "encryption"; "cert" }); | 958 return self:show(match_jid, { "id"; "host"; "dir"; "remote"; "secure"; "encryption"; "cert" }); |
946 end | 959 end |