Mercurial > prosody-modules
annotate mod_rawdebug/mod_rawdebug.lua @ 5173:460f78654864
mod_muc_rtbl: also filter messages
This was a bit tricky because we don't want to run the JIDs
through SHA256 on each message. Took a while to come up with this
simple plan of just caching the SHA256 of the JIDs on the
occupants.
This will leave some dirt in the occupants after unloading the
module, but that should be ok; once they cycle the room, the
hashes will be gone.
This is direly needed, otherwise, there is a tight race between
the moderation activities and the actors joining the room.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Tue, 21 Feb 2023 21:37:27 +0100 |
parents | c5c583fae25d |
children |
rev | line source |
---|---|
1445
ae1d7665cde9
mod_rawdebug: Make global (like mod_admin_telnet)
Kim Alvefur <zash@zash.se>
parents:
1444
diff
changeset
|
1 module:set_global(); |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local tostring = tostring; |
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local filters = require "util.filters"; |
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
2256
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
6 local function log_send(t, session) |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
7 if t and t ~= "" and t ~= " " then |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
8 session.log("debug", "SEND(%d): %s", #t, tostring(t)); |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 end |
2256
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
10 return t; |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 end |
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 |
2256
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
13 local function log_recv(t, session) |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
14 if t and t ~= "" and t ~= " " then |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
15 session.log("debug", "RECV(%d): %s", #t, tostring(t)); |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
2256
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
17 return t; |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 end |
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 |
2256
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
20 local function init_raw_logging(session) |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
21 filters.add_filter(session, "bytes/in", log_recv, -10000); |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
22 filters.add_filter(session, "bytes/out", log_send, 10000); |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 |
2256
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
25 filters.add_filter_hook(init_raw_logging); |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
26 |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
27 function module.unload() -- luacheck: ignore |
c5c583fae25d
mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents:
1445
diff
changeset
|
28 filters.remove_filter_hook(init_raw_logging); |
1444
56c394b9e60d
mod_rawdebug: Adds a telnet command for enabling logging of entire stanzas that are sent and received
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |