Mercurial > prosody-hg
comparison plugins/mod_bosh.lua @ 3070:3238b58fd118
mod_bosh: Add option consider_bosh_secure to treat BOSH sessions as encrypted even if they don't use HTTP (useful for when secure requests are proxied to Prosody over HTTP)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 21 May 2010 19:24:50 +0100 |
| parents | 1fadbb2e3ca0 |
| children | 39a870ae75d9 |
comparison
equal
deleted
inserted
replaced
| 3069:c3df9053e0a9 | 3070:3238b58fd118 |
|---|---|
| 28 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1; | 28 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1; |
| 29 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60; | 29 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60; |
| 30 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; | 30 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; |
| 31 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; | 31 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; |
| 32 local BOSH_DEFAULT_MAXPAUSE = tonumber(module:get_option("bosh_max_pause")) or 300; | 32 local BOSH_DEFAULT_MAXPAUSE = tonumber(module:get_option("bosh_max_pause")) or 300; |
| 33 | |
| 34 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); | |
| 33 | 35 |
| 34 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; | 36 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; |
| 35 local session_close_reply = { headers = default_headers, body = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate" }), attr = {} }; | 37 local session_close_reply = { headers = default_headers, body = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate" }), attr = {} }; |
| 36 | 38 |
| 37 local cross_domain = module:get_option("cross_domain_bosh"); | 39 local cross_domain = module:get_option("cross_domain_bosh"); |
| 175 -- New session | 177 -- New session |
| 176 sid = new_uuid(); | 178 sid = new_uuid(); |
| 177 local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid)-1, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, | 179 local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid)-1, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, |
| 178 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, | 180 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, |
| 179 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream, | 181 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream, |
| 180 dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid), secure = request.secure }; | 182 dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid), secure = consider_bosh_secure or request.secure }; |
| 181 sessions[sid] = session; | 183 sessions[sid] = session; |
| 182 | 184 |
| 183 log("info", "New BOSH session, assigned it sid '%s'", sid); | 185 log("info", "New BOSH session, assigned it sid '%s'", sid); |
| 184 local r, send_buffer = session.requests, session.send_buffer; | 186 local r, send_buffer = session.requests, session.send_buffer; |
| 185 local response = { headers = default_headers } | 187 local response = { headers = default_headers } |
