From 7720a006331e37ecaa243bccd555cf9235d35675 Mon Sep 17 00:00:00 2001 From: Helmut Haensel Date: Wed, 30 Sep 2020 09:59:17 +0200 Subject: [PATCH 1/2] adapt security of ws protocol to http protocol --- files/embedded/channels.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/embedded/channels.js b/files/embedded/channels.js index 56de0c0da..ff006e666 100644 --- a/files/embedded/channels.js +++ b/files/embedded/channels.js @@ -1,7 +1,7 @@ Genie.WebChannels = {}; Genie.WebChannels.load_channels = function() { - let port = Genie.Settings.websockets_port == Genie.Settings.server_port ? window.location.port : Genie.Settings.websockets_port - var socket = new WebSocket('ws://' + window.location.hostname + ':' + port); + let port = Genie.Settings.websockets_port == Genie.Settings.server_port ? window.location.port : Genie.Settings.websockets_port; + var socket = new WebSocket(window.location.protocol.replace("http", "ws") + '//' + window.location.hostname + ':' + port); var channels = Genie.WebChannels; channels.channel = socket; From d218fb9c3e59c22f89d98712261b32017b1a5aff Mon Sep 17 00:00:00 2001 From: Helmut Haensel Date: Wed, 7 Oct 2020 19:26:41 +0200 Subject: [PATCH 2/2] allow for explicit channel specification --- src/Assets.jl | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Assets.jl b/src/Assets.jl index 672de4b4d..e20732467 100644 --- a/src/Assets.jl +++ b/src/Assets.jl @@ -103,8 +103,10 @@ end Outputs the channels.js file included with the Genie package """ -function channels() :: String - string(js_settings(), embedded(joinpath("files", "embedded", "channels.js"))) +function channels(channel::String = Genie.config.webchannels_default_route) :: String + s = string(js_settings(), embedded(joinpath("files", "embedded", "channels.js"))) + channel == Genie.config.webchannels_default_route || (s = replace(s, r"""(?<=webchannels_default_route":")[^"]+""" => channel)) + return s end @@ -113,38 +115,38 @@ end Outputs the channels JavaScript content within `` tags, for embedding into the page. """ -function channels_script() :: String +function channels_script(channel::String = Genie.config.webchannels_default_route) :: String """ """ end """ - channels_support() :: String + channels_support(channel = Genie.config.webchannels_default_route) :: String Provides full web channels support, setting up routes for loading support JS files, web sockets subscription and returning the `" + @info channel + "" end @@ -166,4 +168,4 @@ function favicon_support() :: String "" end -end \ No newline at end of file +end