diff options
author | Kim Alvefur <zash@zash.se> | 2016-12-05 12:23:41 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-12-05 12:23:41 +0100 |
commit | d1eb694c30025990eeed6aef83f0f2a6ff272fd2 (patch) | |
tree | 12f8bbdf7d0ba13ed76086be8ca1e6cf91ab78a8 | |
parent | bcf02d74c72b6a90600f6615c6219952ecbda252 (diff) | |
download | prosody-d1eb694c30025990eeed6aef83f0f2a6ff272fd2.tar.gz prosody-d1eb694c30025990eeed6aef83f0f2a6ff272fd2.zip |
mod_websocket: Add the base URL of each host module is enabled on to 'cross_domain_websocket'
-rw-r--r-- | plugins/mod_websocket.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index 10aa0d38..f6525df5 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -315,4 +315,17 @@ function module.add_host(module) }; }); module:hook("c2s-read-timeout", keepalive, -0.9); + + if cross_domain ~= true then + local url = require "socket.url"; + local ws_url = module:http_url("websocket", "xmpp-websocket"); + local url_components = url.parse(ws_url); + -- The 'Origin' consists of the base URL without path + url_components.path = nil; + local this_origin = url.build(url_components); + cross_domain:add(this_origin); + function module.unload() + cross_domain:remove(this_origin); + end + end end |