mod_stanzadebug/mod_stanzadebug.lua
author Matthew Wild <mwild1@gmail.com>
Tue, 18 Jan 2022 17:01:18 +0000
changeset 4880 0f5f2d4475b9
parent 2492 590ac12b7671
permissions -rw-r--r--
mod_http_xep227: Add support for import via APIs rather than direct store manipulation In particular this transitions PEP nodes and data to be imported via mod_pep's APIs, fixing issues with importing at runtime while PEP data may already be live in RAM. Next obvious candidate for this approach is rosters, so clients get immediate roster pushes and other special handling (such as emitting subscribes to reach the desired subscription state).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1450
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
2260
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
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: 1450
diff changeset
     7
	if t and t ~= "" and t ~= " " then
2492
590ac12b7671 mod_stanzadebug: Like mod_rawdebug but stanzas instead of the raw bytes
Kim Alvefur <zash@zash.se>
parents: 2260
diff changeset
     8
		session.log("debug", "SEND: %s", 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
2260
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
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
2260
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
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: 1450
diff changeset
    14
	if t and t ~= "" and t ~= " " then
2492
590ac12b7671 mod_stanzadebug: Like mod_rawdebug but stanzas instead of the raw bytes
Kim Alvefur <zash@zash.se>
parents: 2260
diff changeset
    15
		session.log("debug", "RECV: %s", 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
2260
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
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
2260
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
    20
local function init_raw_logging(session)
2492
590ac12b7671 mod_stanzadebug: Like mod_rawdebug but stanzas instead of the raw bytes
Kim Alvefur <zash@zash.se>
parents: 2260
diff changeset
    21
	filters.add_filter(session, "stanzas/in",  log_recv, -10000);
590ac12b7671 mod_stanzadebug: Like mod_rawdebug but stanzas instead of the raw bytes
Kim Alvefur <zash@zash.se>
parents: 2260
diff changeset
    22
	filters.add_filter(session, "stanzas/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
2260
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
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: 1450
diff changeset
    26
c5c583fae25d mod_rawdebug: Simplify, remove telnet command, log every single byte
Kim Alvefur <zash@zash.se>
parents: 1450
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: 1450
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