diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/url_helpers.rb | 16 | ||||
-rw-r--r-- | lib/gitlab/workhorse.rb | 14 |
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/gitlab/url_helpers.rb b/lib/gitlab/url_helpers.rb new file mode 100644 index 00000000000..883585c196f --- /dev/null +++ b/lib/gitlab/url_helpers.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Gitlab + class UrlHelpers + WSS_PROTOCOL = "wss".freeze + def self.as_wss(url) + return unless url.present? + + URI.parse(url).tap do |uri| + uri.scheme = WSS_PROTOCOL + end.to_s + rescue URI::InvalidURIError + nil + end + end +end diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 83eabb8d674..533757d2237 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -162,16 +162,16 @@ module Gitlab ] end - def terminal_websocket(terminal) + def channel_websocket(channel) details = { - 'Terminal' => { - 'Subprotocols' => terminal[:subprotocols], - 'Url' => terminal[:url], - 'Header' => terminal[:headers], - 'MaxSessionTime' => terminal[:max_session_time] + 'Channel' => { + 'Subprotocols' => channel[:subprotocols], + 'Url' => channel[:url], + 'Header' => channel[:headers], + 'MaxSessionTime' => channel[:max_session_time] } } - details['Terminal']['CAPem'] = terminal[:ca_pem] if terminal.key?(:ca_pem) + details['Channel']['CAPem'] = channel[:ca_pem] if channel.key?(:ca_pem) details end |