Comparison

plugins/mod_s2s.lua @ 12808:12bd40b8e105

mod_c2s,mod_s2s: Adapt to XEP-xxxx: Stream Limits Advertisement Thanks MattJ
author Kim Alvefur <zash@zash.se>
date Thu, 20 Oct 2022 14:04:56 +0200
parent 12807:f0f7b0c61465
child 12810:871d2c95b403
comparison
equal deleted inserted replaced
12807:f0f7b0c61465 12808:12bd40b8e105
248 module:hook("route/remote", route_to_existing_session, -1); 248 module:hook("route/remote", route_to_existing_session, -1);
249 module:hook("route/remote", route_to_new_session, -10); 249 module:hook("route/remote", route_to_new_session, -10);
250 module:hook("s2s-authenticated", make_authenticated, -1); 250 module:hook("s2s-authenticated", make_authenticated, -1);
251 module:hook("s2s-read-timeout", keepalive, -1); 251 module:hook("s2s-read-timeout", keepalive, -1);
252 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza 252 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza
253 local limits = stanza:get_child("stanza-size-limit", "xmpp:prosody.im/stream/limits"); 253 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0");
254 if limits then 254 if limits then
255 session.outgoing_stanza_size_limit = tonumber(limits.attr.bytes); 255 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-size"));
256 end 256 end
257 if session.type == "s2sout" then 257 if session.type == "s2sout" then
258 -- Stream is authenticated and we are seem to be done with feature negotiation, 258 -- Stream is authenticated and we are seem to be done with feature negotiation,
259 -- so the stream is ready for stanzas. RFC 6120 Section 4.3 259 -- so the stream is ready for stanzas. RFC 6120 Section 4.3
260 mark_connected(session); 260 mark_connected(session);
522 end 522 end
523 523
524 if ( session.type == "s2sin" or session.type == "s2sout" ) or features.tags[1] then 524 if ( session.type == "s2sin" or session.type == "s2sout" ) or features.tags[1] then
525 if stanza_size_limit then 525 if stanza_size_limit then
526 features:reset(); 526 features:reset();
527 features:tag("stanza-size-limit", { xmlns = "xmpp:prosody.im/stream/limits", bytes = string.format("%d", stanza_size_limit) }); 527 features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" })
528 :text_tag("max-size", string.format("%d", stanza_size_limit)):up();
528 end 529 end
529 530
530 log("debug", "Sending stream features: %s", features); 531 log("debug", "Sending stream features: %s", features);
531 session.sends2s(features); 532 session.sends2s(features);
532 else 533 else