sshchat: Replace terminal echo hack with our forked terminal

This commit is contained in:
Andrey Petrov 2019-03-17 17:36:38 -04:00
parent 1ba36b785c
commit 8653f0a730
3 changed files with 3 additions and 10 deletions

2
go.mod
View File

@ -6,5 +6,5 @@ require (
github.com/jessevdk/go-flags v1.4.0
github.com/shazow/rateio v0.0.0-20150116013248-e8e00881e5c1
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a
golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect
golang.org/x/sys v0.0.0-20190312061237-fead79001313
)

View File

@ -146,14 +146,6 @@ func (h *Host) Connect(term *sshd.Terminal) {
break
}
// Gross hack to override line echo in golang.org/x/crypto/ssh/terminal
// It needs to live before we render any responses.
term.Write([]byte{
27, '[', 'A', // Up
27, '[', '2', 'K', // Clear line
})
// May the gods have mercy on our souls.
err = ratelimit.Count(1)
if err != nil {
user.Send(message.NewSystemMsg("Message rejected: Rate limiting is in effect.", user))

View File

@ -7,8 +7,8 @@ import (
"sync"
"time"
"github.com/shazow/ssh-chat/sshd/terminal"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/terminal"
)
var keepaliveInterval = time.Second * 30
@ -81,6 +81,7 @@ func NewTerminal(conn *ssh.ServerConn, ch ssh.NewChannel) (*Terminal, error) {
done: make(chan struct{}),
}
term.Terminal.ClearLine = true
go term.listen(requests)