mod_s2s: Avoid sending too large stanzas
authorKim Alvefur <zash@zash.se>
Tue, 16 Mar 2021 18:30:54 +0100
changeset 12811 f0f7b0c61465
parent 12810 751bdd412915
child 12812 12bd40b8e105
mod_s2s: Avoid sending too large stanzas Just dropping them isn't great but hopefully something more sensible can be done in the future. Will need work to ensure that this signal is handled correctly in sending modules etc.
plugins/mod_s2s.lua
--- a/plugins/mod_s2s.lua	Tue Mar 16 18:30:34 2021 +0100
+++ b/plugins/mod_s2s.lua	Tue Mar 16 18:30:54 2021 +0100
@@ -772,6 +772,11 @@
 		end
 		if t then
 			t = filter("bytes/out", tostring(t));
+			if session.outgoing_stanza_size_limit and #t > session.outgoing_stanza_size_limit then
+				log("warn", "Attempt to send a stanza exceeding session limit of %dB (%dB)!", session.outgoing_stanza_size_limit, #t);
+				-- TODO Pass identifiable error condition back to allow appropriate handling
+				return false
+			end
 			if t then
 				return w(conn, t);
 			end