comparison plugins/mod_s2s.lua @ 13093:93c68c454cb8

mod_c2s,mod_s2s: Fix tag name for SLA (thanks mjk) The (still not published) XEP-xxxx: Stream Limits Advertisement uses the element <max-bytes/> to advertise the maximum octet size of top level stream elements. "size" was probably a leftover of an even earlier version of the (Proto)XEP.
author Kim Alvefur <zash@zash.se>
date Wed, 03 May 2023 18:02:11 +0200
parents 74b9e05af71e
children 8576f94ac90a
comparison
equal deleted inserted replaced
13092:bc46cfe7c037 13093:93c68c454cb8
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("s2sout-stream-features", function (event) 250 module:hook("s2sout-stream-features", function (event)
251 if stanza_size_limit then 251 if stanza_size_limit then
252 event.features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" }) 252 event.features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" })
253 :text_tag("max-size", string.format("%d", stanza_size_limit)):up(); 253 :text_tag("max-bytes", string.format("%d", stanza_size_limit)):up();
254 end 254 end
255 end); 255 end);
256 module:hook_tag("urn:xmpp:bidi", "bidi", function(session, stanza) 256 module:hook_tag("urn:xmpp:bidi", "bidi", function(session, stanza)
257 -- Advertising features on bidi connections where no <stream:features> is sent in the other direction 257 -- Advertising features on bidi connections where no <stream:features> is sent in the other direction
258 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0"); 258 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0");
259 if limits then 259 if limits then
260 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-size")); 260 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-bytes"));
261 end 261 end
262 end, 100); 262 end, 100);
263 module:hook("s2s-authenticated", make_authenticated, -1); 263 module:hook("s2s-authenticated", make_authenticated, -1);
264 module:hook("s2s-read-timeout", keepalive, -1); 264 module:hook("s2s-read-timeout", keepalive, -1);
265 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza 265 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza
266 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0"); 266 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0");
267 if limits then 267 if limits then
268 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-size")); 268 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-bytes"));
269 end 269 end
270 if session.type == "s2sout" then 270 if session.type == "s2sout" then
271 -- Stream is authenticated and we are seem to be done with feature negotiation, 271 -- Stream is authenticated and we are seem to be done with feature negotiation,
272 -- so the stream is ready for stanzas. RFC 6120 Section 4.3 272 -- so the stream is ready for stanzas. RFC 6120 Section 4.3
273 mark_connected(session); 273 mark_connected(session);
536 536
537 if ( session.type == "s2sin" or session.type == "s2sout" ) or features.tags[1] then 537 if ( session.type == "s2sin" or session.type == "s2sout" ) or features.tags[1] then
538 if stanza_size_limit then 538 if stanza_size_limit then
539 features:reset(); 539 features:reset();
540 features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" }) 540 features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" })
541 :text_tag("max-size", string.format("%d", stanza_size_limit)):up(); 541 :text_tag("max-bytes", string.format("%d", stanza_size_limit)):up();
542 end 542 end
543 543
544 log("debug", "Sending stream features: %s", features); 544 log("debug", "Sending stream features: %s", features);
545 session.sends2s(features); 545 session.sends2s(features);
546 else 546 else