Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions internal/http/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ func (h *ConsoleHandler) ServeWS(w http.ResponseWriter, r *http.Request) {
errCh <- err
return
}

var input ssh.Input
if json.Unmarshal(msg, &input) == nil && input.Resize != nil {
inCh <- input
continue
if json.Unmarshal(msg, &input) == nil {
if input.Resize != nil {
inCh <- input
continue
}
if len(input.Data) > 0 {
inCh <- input
continue
}
}

inCh <- ssh.Input{Data: msg}
Expand Down
9 changes: 7 additions & 2 deletions internal/http/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@
setTimeout(function() { fitAddon.fit(); }, 50);

ws = new WebSocket(proto + '//' + host + base + 'api/servers/' + serverId + '/console');
ws.binaryType = 'arraybuffer';

ws.onopen = function() {
document.getElementById('console-status').textContent = 'Connected';
Expand All @@ -421,9 +422,13 @@
};

ws.onmessage = function(evt) {
term.write(evt.data);
var data = evt.data;
if (data instanceof ArrayBuffer) {
term.write(new Uint8Array(data));
} else {
term.write(data);
}
};

ws.onclose = function() {
document.getElementById('console-status').textContent = 'Disconnected';
document.getElementById('console-status').className = 'badge badge-offline';
Expand Down
6 changes: 4 additions & 2 deletions internal/ssh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ func (c *Client) Shell(ctx context.Context, rows, cols int) (<-chan Output, chan
}

if err := session.RequestPty("xterm-256color", rows, cols, gossh.TerminalModes{
gossh.ECHO: 1,
gossh.OCRNL: 1,
gossh.ECHO: 1,
gossh.OCRNL: 1,
gossh.TTY_OP_ISPEED: 14400,
gossh.TTY_OP_OSPEED: 14400,
}); err != nil {
session.Close()
return nil, nil, fmt.Errorf("request pty: %w", err)
Expand Down
Loading