From d126ee88bc666524339830b71141c92bb06cd283 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 10 May 2021 16:44:55 +0100 Subject: util.xmppstream: Reduce default xmppstream limit to 1MB --- util/xmppstream.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/xmppstream.lua') diff --git a/util/xmppstream.lua b/util/xmppstream.lua index 58cbd18e..e2c24c8a 100644 --- a/util/xmppstream.lua +++ b/util/xmppstream.lua @@ -22,7 +22,7 @@ local lxp_supports_doctype = pcall(lxp.new, { StartDoctypeDecl = false }); local lxp_supports_xmldecl = pcall(lxp.new, { XmlDecl = false }); local lxp_supports_bytecount = not not lxp.new({}).getcurrentbytecount; -local default_stanza_size_limit = 1024*1024*10; -- 10MB +local default_stanza_size_limit = 1024*1024*1; -- 1MB local _ENV = nil; -- luacheck: std none -- cgit v1.2.3 From 7cb3ec61d5117fa1be7077ea9efaef4d4e52ca57 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 10 May 2021 17:02:37 +0100 Subject: util.xmppstream: Mark bytes for stream closure as handled --- util/xmppstream.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/xmppstream.lua') diff --git a/util/xmppstream.lua b/util/xmppstream.lua index e2c24c8a..57e1def3 100644 --- a/util/xmppstream.lua +++ b/util/xmppstream.lua @@ -188,6 +188,9 @@ local function new_sax_handlers(session, stream_callbacks, cb_handleprogress) stanza = t_remove(stack); end else + if lxp_supports_bytecount then + cb_handleprogress(stanza_size); + end if cb_streamclosed then cb_streamclosed(session); end -- cgit v1.2.3 From 92cec56e9760c6dc2dc3d775e81646e9995fc6b4 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 10 May 2021 17:03:27 +0100 Subject: util.xmppstream: Allow dynamically configuring the stanza size limit for a stream This may be useful for any plugins that want to experiment with different policies for stanza size limits (e.g. unauthenticated vs authenticated streams). --- util/xmppstream.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/xmppstream.lua') diff --git a/util/xmppstream.lua b/util/xmppstream.lua index 57e1def3..82a9820f 100644 --- a/util/xmppstream.lua +++ b/util/xmppstream.lua @@ -293,6 +293,9 @@ local function new(session, stream_callbacks, stanza_size_limit) return ok, err; end, set_session = meta.set_session; + set_stanza_size_limit = function (_, new_stanza_size_limit) + stanza_size_limit = new_stanza_size_limit; + end; }; end -- cgit v1.2.3