Comparison

plugins/mod_bosh.lua @ 9377:f2013233e20d

mod_bosh: Make BOSH global again!
author Kim Alvefur <zash@zash.se>
date Sat, 22 Sep 2018 00:01:21 +0200
parent 8918:f69b3e39e0c1
child 9380:7425af27fc67
comparison
equal deleted inserted replaced
9376:220468f7a103 9377:f2013233e20d
3 -- Copyright (C) 2008-2010 Waqas Hussain 3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- 4 --
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information. 6 -- COPYING file in the source package for more information.
7 -- 7 --
8
9 module:set_global();
8 10
9 local new_xmpp_stream = require "util.xmppstream".new; 11 local new_xmpp_stream = require "util.xmppstream".new;
10 local sm = require "core.sessionmanager"; 12 local sm = require "core.sessionmanager";
11 local sm_destroy_session = sm.destroy_session; 13 local sm_destroy_session = sm.destroy_session;
12 local new_uuid = require "util.uuid".generate; 14 local new_uuid = require "util.uuid".generate;
271 if not to_host then 273 if not to_host then
272 log("debug", "BOSH client tried to connect to invalid host: %s", tostring(attr.to)); 274 log("debug", "BOSH client tried to connect to invalid host: %s", tostring(attr.to));
273 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", 275 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",
274 ["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" }); 276 ["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" });
275 response:send(tostring(close_reply)); 277 response:send(tostring(close_reply));
276 return;
277 elseif to_host ~= module.host then
278 -- Could be meant for a different instance of the module
279 -- if multiple instances are loaded with the same URL then this can happen
280 context.ignore_request = true;
281 return; 278 return;
282 end 279 end
283 if not rid or (not wait and attr.wait or wait < 0 or wait % 1 ~= 0) then 280 if not rid or (not wait and attr.wait or wait < 0 or wait % 1 ~= 0) then
284 log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", tostring(attr.rid), tostring(attr.wait)); 281 log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", tostring(attr.rid), tostring(attr.wait));
285 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", 282 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",