aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-05 12:23:41 +0100
committerKim Alvefur <zash@zash.se>2016-12-05 12:23:41 +0100
commita6443e8ff35cadd1ec395d8d464e4d7119fb1259 (patch)
tree12f8bbdf7d0ba13ed76086be8ca1e6cf91ab78a8 /plugins
parent947faa1ccd09773d64d6fca51430b9832e15d72e (diff)
downloadprosody-a6443e8ff35cadd1ec395d8d464e4d7119fb1259.tar.gz
prosody-a6443e8ff35cadd1ec395d8d464e4d7119fb1259.zip
mod_websocket: Add the base URL of each host module is enabled on to 'cross_domain_websocket'
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_websocket.lua13
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