mirror of
https://github.com/syssecfsu/witty.git
synced 2025-01-25 19:44:24 +01:00
wip
This commit is contained in:
parent
e9241e7a6e
commit
cd895cfef7
@ -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.
|
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 <sub>featuring an older version of WiTTY</sub>
|
## An Screencast <sub>featuring an older version of WiTTY</sub>
|
||||||
|
|
||||||
Here is a screencast for sshing into Raspberry Pi running
|
Here is a screencast for sshing into Raspberry Pi running
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#terminal {
|
#terminal {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin: 20px 0 50px;
|
margin: 10px 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#terminal #terminal_view {
|
#terminal #terminal_view {
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background-color: #282a36;
|
background-color: #282a36;
|
||||||
max-width: 860px;
|
max-width: 880px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.xterm-viewport.xterm-viewport {
|
.xterm-viewport.xterm-viewport {
|
||||||
|
@ -32,7 +32,7 @@ function createTerminal(path) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
term.open(document.getElementById('terminal_view'));
|
term.open(document.getElementById('terminal_view'));
|
||||||
term.resize(122, 37);
|
term.resize(124, 37);
|
||||||
|
|
||||||
const weblinksAddon = new WebLinksAddon.WebLinksAddon();
|
const weblinksAddon = new WebLinksAddon.WebLinksAddon();
|
||||||
term.loadAddon(weblinksAddon);
|
term.loadAddon(weblinksAddon);
|
||||||
@ -45,6 +45,7 @@ function createTerminal(path) {
|
|||||||
// create the websocket and connect to the server
|
// create the websocket and connect to the server
|
||||||
const ws_uri = "wss://" + window.location.host + path;
|
const ws_uri = "wss://" + window.location.host + path;
|
||||||
const socket = new WebSocket(ws_uri);
|
const socket = new WebSocket(ws_uri);
|
||||||
|
socket.binaryType = "arraybuffer";
|
||||||
const attachAddon = new AttachAddon.AttachAddon(socket);
|
const attachAddon = new AttachAddon.AttachAddon(socket);
|
||||||
term.loadAddon(attachAddon);
|
term.loadAddon(attachAddon);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="margin-top: 7em;">
|
<div style="margin-top: 5em;">
|
||||||
<div id="terminal">
|
<div id="terminal">
|
||||||
<div id="terminal_view"></div>
|
<div id="terminal_view"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
// print something to test output and scroll
|
// print something to test output and scroll
|
||||||
var str = [
|
var str = [
|
||||||
' ┌────────────────────────────────────────────────────────────────────────────┐\n',
|
' ┌────────────────────────────────────────────────────────────────────────────┐\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',
|
' └────────────────────────────────────────────────────────────────────────────┘\n',
|
||||||
''
|
''
|
||||||
].join('');
|
].join('');
|
||||||
|
@ -209,7 +209,7 @@ out:
|
|||||||
// We could add ws to viewers as well (then we can use io.MultiWriter),
|
// We could add ws to viewers as well (then we can use io.MultiWriter),
|
||||||
// but we want to handle errors differently
|
// but we want to handle errors differently
|
||||||
tc.ws.SetWriteDeadline(time.Now().Add(writeWait))
|
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)
|
log.Println("Failed to write message: ", err)
|
||||||
break out
|
break out
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ out:
|
|||||||
|
|
||||||
// if the viewer exits, we will just ignore the error
|
// if the viewer exits, we will just ignore the error
|
||||||
w.SetWriteDeadline(time.Now().Add(viewWait))
|
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)
|
log.Println("Failed to write message to viewer: ", err)
|
||||||
|
|
||||||
viewers[i] = nil
|
viewers[i] = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user