comparison plugins/mod_c2s.lua @ 14154:363a79f54109 0.12

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 fed0dd8dda09
children ead9e645741a
comparison
equal deleted inserted replaced
14153:aa29d5144c20 14154:363a79f54109
28 local c2s_timeout = module:get_option_number("c2s_timeout", 300); 28 local c2s_timeout = module:get_option_number("c2s_timeout", 300);
29 local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); 29 local stream_close_timeout = module:get_option_number("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_number("c2s_unauthed_stanza_size_limit", 10000,1000); 31 local unauthed_stanza_size_limit = module:get_option_number("c2s_unauthed_stanza_size_limit", 10000,1000);
32 local authed_stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 1024*256,10000); 32 local authed_stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 1024*256,10000);
33 local max_child_elements = module:get_option_number("c2s_max_child_elements", 25000, 0);
33 34
34 local measure_connections = module:metric("gauge", "connections", "", "Established c2s connections", {"host", "type", "ip_family"}); 35 local measure_connections = module:metric("gauge", "connections", "", "Established c2s connections", {"host", "type", "ip_family"});
35 36
36 local sessions = module:shared("sessions"); 37 local sessions = module:shared("sessions");
37 local core_process_stanza = prosody.core_process_stanza; 38 local core_process_stanza = prosody.core_process_stanza;
313 314
314 session.close = session_close; 315 session.close = session_close;
315 316
316 session.stanza_size_limit = unauthed_stanza_size_limit; 317 session.stanza_size_limit = unauthed_stanza_size_limit;
317 318
318 local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit); 319 local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit, {
320 max_elements = max_child_elements;
321 });
319 session.stream = stream; 322 session.stream = stream;
320 session.notopen = true; 323 session.notopen = true;
321 324
322 function session.reset_stream() 325 function session.reset_stream()
323 session.notopen = true; 326 session.notopen = true;