fix: fix ssh bug (#99)

This commit is contained in:
naison
2023-11-28 20:21:11 +08:00
committed by GitHub
parent 5cc64d17c2
commit abf36b87a6
3 changed files with 77 additions and 15 deletions

View File

@@ -196,19 +196,11 @@ func (w *wsHandler) terminal(conf *util.SshConfig, conn *websocket.Conn) error {
session.Stdin = conn
fd := int(os.Stdin.Fd())
if !terminal.IsTerminal(fd) {
state, err := terminal.MakeRaw(fd)
if err != nil {
w.Log("Terminal make raw: %s", err)
return fmt.Errorf("terminal make raw: %s", err)
}
defer terminal.Restore(fd, state)
}
width, height, err := terminal.GetSize(fd)
if err != nil {
w.Log("Terminal get size: %s", err)
return fmt.Errorf("terminal get size: %s", err)
width = 80
height = 40
}
modes := ssh.TerminalModes{
ssh.ECHO: 1,
@@ -302,7 +294,7 @@ func (w *wsHandler) Log(format string, a ...any) {
if len(a) != 0 {
str = fmt.Sprintf(format, a...)
}
w.conn.Write([]byte(str + "\n"))
w.conn.Write([]byte(str + "\r\n"))
}
func (w *wsHandler) PrintLine(msg string) {