From fea7050b1e870d1f980093da205197bf58867e06 Mon Sep 17 00:00:00 2001 From: Mickael Kerjean Date: Fri, 17 May 2019 04:03:44 +1000 Subject: [PATCH] fix (console): wss issue --- .drone.yml | 5 +++-- server/plugin/plg_handler_console/index.go | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index d77dc647..6c7d8d91 100644 --- a/.drone.yml +++ b/.drone.yml @@ -47,9 +47,9 @@ steps: from_secret: GIT_PASSWORD commands: - apk add git > /dev/null + - chmod -R o+r+w+x ./dist/data - cd ../ && git clone "https://readonly:$PASSWORD@git.kerjean.me/filestash/test.git" - chmod -R 777 ./test/ - - chmod -R 777 ./filestash/dist/data - name: test_frontend image: node:8-alpine @@ -91,7 +91,8 @@ steps: GPG_PASSPHRASE: from_secret: GPG_PASSPHRASE commands: - - cp -R config/* dist/data/state/config/ + - cp -R config/* ./dist/data/state/config/ + - chmod -R o-r-w-x- ./dist/ - apt-get update > /dev/null && apt-get install -y gnupg1 curl > /dev/null - mv dist filestash - tar -cf filestash_linux-amd64.tar ./filestash diff --git a/server/plugin/plg_handler_console/index.go b/server/plugin/plg_handler_console/index.go index e18670b4..829f8e58 100644 --- a/server/plugin/plg_handler_console/index.go +++ b/server/plugin/plg_handler_console/index.go @@ -66,7 +66,7 @@ func AuthBasic(credentials func() (string, string), fn http.Handler) http.Handle http.NotFoundHandler().ServeHTTP(res, req) return } - + auth := req.Header.Get("Authorization") if strings.HasPrefix(auth, "Basic ") == false { notAuthorised(res, req) @@ -273,6 +273,7 @@ func htmlIndex(pathPrefix string) []byte { func AppScript(pathPrefix string) string { return ` + (function() { Terminal.applyAddon(fit); var term; @@ -302,7 +303,7 @@ func AppScript(pathPrefix string) string { }); var websocket = new WebSocket( - (location.protocol === "https:") ? "wss://" : "ws://" + + (location.protocol === "https:" ? "wss://" : "ws://") + location.hostname + ((location.port) ? (":" + location.port) : "") + "`+ pathPrefix +`socket" ); @@ -343,7 +344,9 @@ func AppScript(pathPrefix string) string { } websocket.onerror = function(e){ - term.destroy(); + var $term = document.getElementById("terminal"); + if($term) $term.remove(); + document.getElementById("terminal").remove() document.getElementById("error-message").innerText = "Websocket Error"; } }