From cd895cfef7e586c370ae2fb6feaec4cd181edbe8 Mon Sep 17 00:00:00 2001 From: Zhi Wang Date: Wed, 12 Jan 2022 07:33:06 -0500 Subject: [PATCH] wip --- README.md | 4 ++++ assets/main.css | 4 ++-- assets/main.js | 3 ++- assets/term.html | 4 ++-- term_conn/relay.go | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e04784c..53e31b6 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ window (xterm.js) and create a websocket with the server, which relays the data The program has been tested on Linux, WSL2, Raspberry Pi 3B (Debian), and MacOSX using Google Chrome, Firefox, and Safari. +## Known bug + +WiTTY has some display/encoding issues on macOS with Firefox, especially for zsh. Safari works fine though. + ## An Screencast featuring an older version of WiTTY Here is a screencast for sshing into Raspberry Pi running diff --git a/assets/main.css b/assets/main.css index 40a44fa..ab73e72 100644 --- a/assets/main.css +++ b/assets/main.css @@ -1,14 +1,14 @@ #terminal { display: flex; justify-content: center; - margin: 20px 0 50px; + margin: 10px 0 20px; } #terminal #terminal_view { padding: 10px 20px; border-radius: 6px; background-color: #282a36; - max-width: 860px; + max-width: 880px; } .xterm-viewport.xterm-viewport { diff --git a/assets/main.js b/assets/main.js index c3ca192..63bfc24 100644 --- a/assets/main.js +++ b/assets/main.js @@ -32,7 +32,7 @@ function createTerminal(path) { }); term.open(document.getElementById('terminal_view')); - term.resize(122, 37); + term.resize(124, 37); const weblinksAddon = new WebLinksAddon.WebLinksAddon(); term.loadAddon(weblinksAddon); @@ -45,6 +45,7 @@ function createTerminal(path) { // create the websocket and connect to the server const ws_uri = "wss://" + window.location.host + path; const socket = new WebSocket(ws_uri); + socket.binaryType = "arraybuffer"; const attachAddon = new AttachAddon.AttachAddon(socket); term.loadAddon(attachAddon); diff --git a/assets/term.html b/assets/term.html index 8b2ff33..789f4d6 100644 --- a/assets/term.html +++ b/assets/term.html @@ -28,7 +28,7 @@ -
+
@@ -39,7 +39,7 @@ // print something to test output and scroll var str = [ ' ┌────────────────────────────────────────────────────────────────────────────┐\n', - ' │ Powered by \u001b[32;1mGo, Gin, websocket, pty, and https://xtermjs.org\x1b[0m │\n', + ' │ Powered by \u001b[32;1mGo, Gin, websocket, pty, and xterm.js\x1b[0m │\n', ' └────────────────────────────────────────────────────────────────────────────┘\n', '' ].join(''); diff --git a/term_conn/relay.go b/term_conn/relay.go index c8e3080..30ce908 100644 --- a/term_conn/relay.go +++ b/term_conn/relay.go @@ -209,7 +209,7 @@ out: // We could add ws to viewers as well (then we can use io.MultiWriter), // but we want to handle errors differently tc.ws.SetWriteDeadline(time.Now().Add(writeWait)) - if err := tc.ws.WriteMessage(websocket.TextMessage, buf); err != nil { + if err := tc.ws.WriteMessage(websocket.BinaryMessage, buf); err != nil { log.Println("Failed to write message: ", err) break out } @@ -222,7 +222,7 @@ out: // if the viewer exits, we will just ignore the error w.SetWriteDeadline(time.Now().Add(viewWait)) - if err := w.WriteMessage(websocket.TextMessage, buf); err != nil { + if err := w.WriteMessage(websocket.BinaryMessage, buf); err != nil { log.Println("Failed to write message to viewer: ", err) viewers[i] = nil