Mercurial > prosody-hg
comparison plugins/mod_bosh.lua @ 14138:c1469296190d
Merge 13.0->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 17 Apr 2026 14:35:32 +0100 |
| parents | 44f859531df7 a4327478678f |
| children |
comparison
equal
deleted
inserted
replaced
| 14121:7008869fcce2 | 14138:c1469296190d |
|---|---|
| 43 -- (the client can set this to a lower value when it connects, if it chooses) | 43 -- (the client can set this to a lower value when it connects, if it chooses) |
| 44 local bosh_max_wait = module:get_option_period("bosh_max_wait", 120); | 44 local bosh_max_wait = module:get_option_period("bosh_max_wait", 120); |
| 45 | 45 |
| 46 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); | 46 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); |
| 47 local cross_domain = module:get_option("cross_domain_bosh"); | 47 local cross_domain = module:get_option("cross_domain_bosh"); |
| 48 local stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256, 10000); | 48 local unauthed_stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 10000, 1000); |
| 49 | 49 |
| 50 if cross_domain ~= nil then | 50 if cross_domain ~= nil then |
| 51 module:log("info", "The 'cross_domain_bosh' option has been deprecated"); | 51 module:log("info", "The 'cross_domain_bosh' option has been deprecated"); |
| 52 end | 52 end |
| 53 | 53 |
| 122 local log = request.log or log; | 122 local log = request.log or log; |
| 123 response.on_destroy = on_destroy_request; | 123 response.on_destroy = on_destroy_request; |
| 124 local body = request.body; | 124 local body = request.body; |
| 125 | 125 |
| 126 local context = { request = request, response = response, notopen = true }; | 126 local context = { request = request, response = response, notopen = true }; |
| 127 local stream = new_xmpp_stream(context, stream_callbacks, stanza_size_limit); | 127 local stream = new_xmpp_stream(context, stream_callbacks, unauthed_stanza_size_limit); |
| 128 response.context = context; | 128 response.context = context; |
| 129 context.stream = stream; | |
| 129 | 130 |
| 130 local headers = response.headers; | 131 local headers = response.headers; |
| 131 headers.content_type = "text/xml; charset=utf-8"; | 132 headers.content_type = "text/xml; charset=utf-8"; |
| 132 | 133 |
| 133 -- stream:feed() calls the stream_callbacks, so all stanzas in | 134 -- stream:feed() calls the stream_callbacks, so all stanzas in |
| 334 session.streamid = sid; | 335 session.streamid = sid; |
| 335 session.bosh_max_inactive = bosh_max_inactivity; | 336 session.bosh_max_inactive = bosh_max_inactivity; |
| 336 session.bosh_responses = cache.new(BOSH_HOLD + 1):table(); | 337 session.bosh_responses = cache.new(BOSH_HOLD + 1):table(); |
| 337 session.requests = {}; | 338 session.requests = {}; |
| 338 session.send_buffer = {}; | 339 session.send_buffer = {}; |
| 340 session.stanza_size_limit = unauthed_stanza_size_limit; | |
| 339 session.reset_stream = bosh_reset_stream; | 341 session.reset_stream = bosh_reset_stream; |
| 340 session.close = bosh_close_stream; | 342 session.close = bosh_close_stream; |
| 341 session.dispatch_stanza = core_process_stanza; | 343 session.dispatch_stanza = core_process_stanza; |
| 342 session.notopen = true; | 344 session.notopen = true; |
| 343 session.secure = consider_bosh_secure or request.secure; | 345 session.secure = consider_bosh_secure or request.secure; |
| 409 context.notopen = nil; | 411 context.notopen = nil; |
| 410 return; | 412 return; |
| 411 end | 413 end |
| 412 | 414 |
| 413 session.conn = request.conn; | 415 session.conn = request.conn; |
| 416 session.stream = context.stream; | |
| 417 | |
| 418 if session.stanza_size_limit then | |
| 419 session.stream:set_stanza_size_limit(session.stanza_size_limit); | |
| 420 end | |
| 414 | 421 |
| 415 if session.rid then | 422 if session.rid then |
| 416 local diff = rid - session.rid; | 423 local diff = rid - session.rid; |
| 417 -- Diff should be 1 for a healthy request | 424 -- Diff should be 1 for a healthy request |
| 418 session.log("debug", "rid: %d, sess: %s, diff: %d", rid, session.rid, diff) | 425 session.log("debug", "rid: %d, sess: %s, diff: %d", rid, session.rid, diff) |
| 546 -- <p>For more information see <a href="https://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p> | 553 -- <p>For more information see <a href="https://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p> |
| 547 }) or "This is the Prosody BOSH endpoint."; | 554 }) or "This is the Prosody BOSH endpoint."; |
| 548 end | 555 end |
| 549 | 556 |
| 550 function module.add_host(module) | 557 function module.add_host(module) |
| 558 module:depends("c2s"); -- updates stanza_size_limit on authentication | |
| 551 module:depends("http"); | 559 module:depends("http"); |
| 552 module:provides("http", { | 560 module:provides("http", { |
| 553 default_path = "/http-bind"; | 561 default_path = "/http-bind"; |
| 554 cors = { | 562 cors = { |
| 555 enabled = true; | 563 enabled = true; |
