Changeset

12807:f0f7b0c61465

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.
author Kim Alvefur <zash@zash.se>
date Tue, 16 Mar 2021 18:30:54 +0100
parents 12806:751bdd412915
children 12808:12bd40b8e105
files plugins/mod_s2s.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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