Comparison

plugins/mod_websocket.lua @ 7764:d6b96e42e8e6

mod_websocket: Allow per-host cross_domain_websocket, defaulting to the base URL of the current host
author Kim Alvefur <zash@zash.se>
date Mon, 05 Dec 2016 12:23:51 +0100
parent 7763:c5ce14539fc4
child 7914:a6eb3b6bf903
comparison
equal deleted inserted replaced
7763:c5ce14539fc4 7764:d6b96e42e8e6
321 local ws_url = module:http_url("websocket", "xmpp-websocket"); 321 local ws_url = module:http_url("websocket", "xmpp-websocket");
322 local url_components = url.parse(ws_url); 322 local url_components = url.parse(ws_url);
323 -- The 'Origin' consists of the base URL without path 323 -- The 'Origin' consists of the base URL without path
324 url_components.path = nil; 324 url_components.path = nil;
325 local this_origin = url.build(url_components); 325 local this_origin = url.build(url_components);
326 cross_domain:add(this_origin); 326 local local_cross_domain = module:get_option_set("cross_domain_websocket", { this_origin });
327 -- Don't add / remove something added by another host
328 -- This might be weird with random load order
329 local_cross_domain:exclude(cross_domain);
330 cross_domain:include(local_cross_domain);
327 function module.unload() 331 function module.unload()
328 cross_domain:remove(this_origin); 332 cross_domain:exclude(local_cross_domain);
329 end 333 end
330 end 334 end
331 end 335 end