comparison plugins/mod_c2s.lua @ 14132:1e005ba71f0d 13.0

mod_c2s, mod_s2s: Add configurable limit for stanza max child elements
author Matthew Wild <mwild1@gmail.com>
date Thu, 16 Apr 2026 18:53:34 +0100
parents 863da67a4b51
children 836a70deb3c9
comparison
equal deleted inserted replaced
14131:6c7549964d4d 14132:1e005ba71f0d
28 local c2s_timeout = module:get_option_period("c2s_timeout", "5 minutes"); 28 local c2s_timeout = module:get_option_period("c2s_timeout", "5 minutes");
29 local stream_close_timeout = module:get_option_period("c2s_close_timeout", 5); 29 local stream_close_timeout = module:get_option_period("c2s_close_timeout", 5);
30 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); 30 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
31 local unauthed_stanza_size_limit = module:get_option_integer("c2s_unauthed_stanza_size_limit", 10000,1000); 31 local unauthed_stanza_size_limit = module:get_option_integer("c2s_unauthed_stanza_size_limit", 10000,1000);
32 local authed_stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256,10000); 32 local authed_stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256,10000);
33 local max_child_elements = module:get_option_integer("c2s_max_child_elements", 25000, 0);
33 34
34 local advertised_idle_timeout = 14*60; -- default in all net.server implementations 35 local advertised_idle_timeout = 14*60; -- default in all net.server implementations
35 local network_settings = module:get_option("network_settings"); 36 local network_settings = module:get_option("network_settings");
36 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then 37 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then
37 advertised_idle_timeout = network_settings.read_timeout; 38 advertised_idle_timeout = network_settings.read_timeout;
353 354
354 session.close = session_close; 355 session.close = session_close;
355 356
356 session.stanza_size_limit = unauthed_stanza_size_limit; 357 session.stanza_size_limit = unauthed_stanza_size_limit;
357 358
358 local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit); 359 local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit, {
360 max_elements = max_child_elements;
361 });
359 session.stream = stream; 362 session.stream = stream;
360 session.notopen = true; 363 session.notopen = true;
361 364
362 function session.reset_stream() 365 function session.reset_stream()
363 session.notopen = true; 366 session.notopen = true;