diff options
author | Kim Alvefur <zash@zash.se> | 2019-06-10 13:22:22 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-06-10 13:22:22 +0200 |
commit | 5eba0ea836d508aeb3087a7d93f6e90cc1f92de8 (patch) | |
tree | 8cd84a76fb673cbfefa00ba1516bd16150f1c780 /plugins/mod_websocket.lua | |
parent | 1cc4ec5d808a55d32e3d51f30d8b50fe45268438 (diff) | |
parent | 2bb05d010d9b237a088bd9b4c997451407191d3f (diff) | |
download | prosody-5eba0ea836d508aeb3087a7d93f6e90cc1f92de8.tar.gz prosody-5eba0ea836d508aeb3087a7d93f6e90cc1f92de8.zip |
Merge 0.11->trunk
Diffstat (limited to 'plugins/mod_websocket.lua')
-rw-r--r-- | plugins/mod_websocket.lua | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index b4aba338..008f6823 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -29,18 +29,10 @@ local t_concat = table.concat; local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); local consider_websocket_secure = module:get_option_boolean("consider_websocket_secure"); -local cross_domain = module:get_option_set("cross_domain_websocket", {}); -if cross_domain:contains("*") or cross_domain:contains(true) then - cross_domain = true; +local cross_domain = module:get_option("cross_domain_websocket"); +if cross_domain ~= nil then + module:log("info", "The 'cross_domain_websocket' option has been deprecated"); end - -local function check_origin(origin) - if cross_domain == true then - return true; - end - return cross_domain:contains(origin); -end - local xmlns_framing = "urn:ietf:params:xml:ns:xmpp-framing"; local xmlns_streams = "http://etherx.jabber.org/streams"; local xmlns_client = "jabber:client"; @@ -158,11 +150,6 @@ function handle_request(event) return 501; end - if not check_origin(request.headers.origin or "") then - module:log("debug", "Origin %s is not allowed by 'cross_domain_websocket' [ %s ]", request.headers.origin or "(missing header)", cross_domain); - return 403; - end - local function websocket_close(code, message) conn:write(build_close(code, message)); conn:close(); @@ -329,27 +316,4 @@ module:provides("http", { 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); - local local_cross_domain = module:get_option_set("cross_domain_websocket", { this_origin }); - if local_cross_domain:contains(true) then - module:log("error", "cross_domain_websocket = true only works in the global section"); - return; - end - - -- Don't add / remove something added by another host - -- This might be weird with random load order - local_cross_domain:exclude(cross_domain); - cross_domain:include(local_cross_domain); - module:log("debug", "cross_domain = %s", tostring(cross_domain)); - function module.unload() - cross_domain:exclude(local_cross_domain); - end - end end |