comparison plugins/mod_s2s.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 791426dda30d
children c1469296190d 18d364587db5
comparison
equal deleted inserted replaced
14131:6c7549964d4d 14132:1e005ba71f0d
41 local secure_domains, insecure_domains = 41 local secure_domains, insecure_domains =
42 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; 42 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items;
43 local require_encryption = module:get_option_boolean("s2s_require_encryption", true); 43 local require_encryption = module:get_option_boolean("s2s_require_encryption", true);
44 local unauthed_stanza_size_limit = module:get_option_integer("s2s_unauthed_stanza_size_limit", 10000, 1000); 44 local unauthed_stanza_size_limit = module:get_option_integer("s2s_unauthed_stanza_size_limit", 10000, 1000);
45 local authed_stanza_size_limit = module:get_option_integer("s2s_stanza_size_limit", 1024*512, 10000); 45 local authed_stanza_size_limit = module:get_option_integer("s2s_stanza_size_limit", 1024*512, 10000);
46 local max_child_elements = module:get_option_integer("s2s_max_child_elements", 25000, 0);
46 local sendq_size = module:get_option_integer("s2s_send_queue_size", 1024*32, 1); 47 local sendq_size = module:get_option_integer("s2s_send_queue_size", 1024*32, 1);
47 48
48 local advertised_idle_timeout = 14*60; -- default in all net.server implementations 49 local advertised_idle_timeout = 14*60; -- default in all net.server implementations
49 local network_settings = module:get_option("network_settings"); 50 local network_settings = module:get_option("network_settings");
50 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then 51 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then
799 end 800 end
800 end 801 end
801 802
802 -- Session initialization logic shared by incoming and outgoing 803 -- Session initialization logic shared by incoming and outgoing
803 local function initialize_session(session) 804 local function initialize_session(session)
804 local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit or unauthed_stanza_size_limit); 805 local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit, {
806 max_elements = max_child_elements;
807 });
805 808
806 session.thread = runner(function (item) 809 session.thread = runner(function (item)
807 if st.is_stanza(item) then 810 if st.is_stanza(item) then
808 core_process_stanza(session, item); 811 core_process_stanza(session, item);
809 else 812 else