# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1590957574 -7200
# Node ID ece430d4980997b216c2240015bf922bdeb12dd6
# Parent  590ac42d81c534b306140e48c4a046619eb656e6
mod_c2s,mod_s2s: Make stanza size limits configurable

diff -r 590ac42d81c5 -r ece430d49809 plugins/mod_c2s.lua
--- a/plugins/mod_c2s.lua	Wed Sep 30 09:46:30 2020 +0100
+++ b/plugins/mod_c2s.lua	Sun May 31 22:39:34 2020 +0200
@@ -26,6 +26,7 @@
 local c2s_timeout = module:get_option_number("c2s_timeout", 300);
 local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5);
 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
+local stanza_size_limit = module:get_option_number("c2s_stanza_size_limit"); -- TODO come up with a sensible default (util.xmppstream defaults to 10M)
 
 local measure_connections = module:measure("connections", "amount");
 local measure_ipv6 = module:measure("ipv6", "amount");
@@ -262,7 +263,7 @@
 
 	session.close = session_close;
 
-	local stream = new_xmpp_stream(session, stream_callbacks);
+	local stream = new_xmpp_stream(session, stream_callbacks, stanza_size_limit);
 	session.stream = stream;
 	session.notopen = true;
 
diff -r 590ac42d81c5 -r ece430d49809 plugins/mod_s2s/mod_s2s.lua
--- a/plugins/mod_s2s/mod_s2s.lua	Wed Sep 30 09:46:30 2020 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Sun May 31 22:39:34 2020 +0200
@@ -37,6 +37,7 @@
 local secure_domains, insecure_domains =
 	module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items;
 local require_encryption = module:get_option_boolean("s2s_require_encryption", false);
+local stanza_size_limit = module:get_option_number("s2s_stanza_size_limit"); -- TODO come up with a sensible default (util.xmppstream defaults to 10M)
 
 local measure_connections = module:measure("connections", "amount");
 local measure_ipv6 = module:measure("ipv6", "amount");
@@ -550,7 +551,7 @@
 
 -- Session initialization logic shared by incoming and outgoing
 local function initialize_session(session)
-	local stream = new_xmpp_stream(session, stream_callbacks);
+	local stream = new_xmpp_stream(session, stream_callbacks, stanza_size_limit);
 
 	session.thread = runner(function (stanza)
 		if stanza.name == nil then