Mercurial > prosody-modules
annotate mod_measure_muc/mod_measure_muc.lua @ 6319:04c3273cb81f
mod_auth_cyrus: Add empty 'profile' table to SASL handler objects
This is for compatibility with Prosody's built-in util.sasl objects.
A SASL profile table usually includes methods supported by the backend, which
can be used by SASL mechanism handlers to perform operations (such as testing
the password). It also optionally contains a 'cb' field with channel binding
method handlers.
The Cyrus backend doesn't support channel binding, and doesn't have the same
concept of auth backend methods (it handles all that internally, and Prosody
has no insight or control over it).
Thus, we create an empty profile which informs Prosody that the SASL handler
does not support any of the auth or channel binding methods. Some features
will not work, but they didn't work anyway. This just makes it explicit.
This fixes a traceback in mod_sasl2_fast, which expected SASL handlers to
always contain a 'profile' field.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 04 Sep 2025 10:14:46 +0100 |
| parents | 39931d727c22 |
| children |
| rev | line source |
|---|---|
|
3969
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
1 -- Group Chat statistics |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
2 -- |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
3 -- Copyright (C) 2020 kaliko <kaliko@azylum.org> |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
4 -- |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
5 -- This module is MIT/X11 licensed. |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
6 |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
7 -- https://prosody.im/doc/developers/modules |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
8 -- https://prosody.im/doc/developers/moduleapi |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
9 -- https://prosody.im/doc/statistics |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
10 |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
11 module:log("info", "loading mod_%s", module.name); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
12 if module:get_host_type() ~= "component" then |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
13 module:log("error", "mod_%s should be loaded only on a MUC component, not normal hosts", module.name); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
14 return; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
15 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
16 |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
17 local mod_muc = module:depends"muc"; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
18 local all_rooms = rawget(mod_muc, "all_rooms") |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
19 |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
20 -- Add relevant boolean MUC metrics here |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
21 local counters = { |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
22 hidden = module:measure("hidden", "amount", 0), |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
23 persistent = module:measure("persistent", "amount", 0), |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
24 password = module:measure('passwd', "amount", 0), |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
25 archiving = module:measure('archiving', 'amount', 0), |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
26 }; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
27 local total_counter = module:measure("total", "amount", 0); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
28 |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
29 module:hook_global("stats-update", function () |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
30 local total = 0; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
31 local buckets = {}; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
32 -- Init buckets |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
33 for bucket, _ in pairs(counters) do |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
34 buckets[bucket] = 0; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
35 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
36 for room in all_rooms() do |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
37 --[[ |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
38 module:log('debug', 'room data for : "'..room.jid..'"'); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
39 for conf, val in pairs(room._data) do |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
40 module:log('debug', conf..": "..tostring(val)); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
41 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
42 ]]-- |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
43 total = total + 1; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
44 --module:log('debug','buckets room data :'); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
45 for bucket, _ in pairs(buckets) do |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
46 --module:log('debug', bucket..": "..tostring(room._data[bucket])); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
47 if room._data[bucket] then |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
48 buckets[bucket] = buckets[bucket] + 1; |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
49 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
50 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
51 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
52 for bucket, count in pairs(buckets) do |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
53 counters[bucket](count) |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
54 end |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
55 total_counter(total); |
|
39931d727c22
mod_measure_muc: Collect statistics on Grout Chat
kaliko <kaliko@azylum.org>
parents:
diff
changeset
|
56 end) |
