From 5a96b432e76c594a9dec1a7d9f7c2f750011c04d Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Fri, 16 Mar 2018 20:32:04 +0300 Subject: [PATCH] Fixed incorrect proxying to WebSocket remote (fixes #178) --- docs/quota-files.adoc | 4 ++-- proxy.go | 2 +- proxy_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/quota-files.adoc b/docs/quota-files.adoc index 47d95c6..3ec5479 100644 --- a/docs/quota-files.adoc +++ b/docs/quota-files.adoc @@ -54,11 +54,11 @@ Two notations are supported in `vnc` attribute: . If the remote server also returns VNC traffic on a web socket (which is a case for http://aerokube.com/selenoid/latest/#_live_browser_screen[Selenoid]) - then you should specify a `ws://` URL without trailing `` value: + - ws://my-selenoid-host.example.com/vnc + ws://my-selenoid-host.example.com:4444/vnc + Having this URL Ggr will append session ID and proxy VNC traffic from: + - ws://my-selenoid-host.example.com/vnc/ + ws://my-selenoid-host.example.com:4444/vnc/ === Working with External Selenium Services diff --git a/proxy.go b/proxy.go index 5c2e053..7c747f1 100644 --- a/proxy.go +++ b/proxy.go @@ -535,7 +535,7 @@ func vnc(wsconn *websocket.Conn) { port = vncInfo.Port path = vncInfo.Path } - sessionID := strings.Split(wsconn.Request().URL.Path, "/")[2] + sessionID := strings.Split(wsconn.Request().URL.Path, "/")[2][md5SumLength:] switch scheme { case vncScheme: proxyVNC(id, wsconn, sessionID, host, port) diff --git a/proxy_test.go b/proxy_test.go index d31c2cc..fffb1ce 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -251,7 +251,7 @@ func TestProxyScreenWebSocketsProtocol(t *testing.T) { const testData = "ws-data" mux := http.NewServeMux() - mux.Handle("/vnc/", websocket.Handler(func(wsconn *websocket.Conn) { + mux.Handle("/vnc/123", websocket.Handler(func(wsconn *websocket.Conn) { wsconn.Write([]byte(testData)) }))