sshchat: Fix empty messages borking rendering

This commit is contained in:
Andrey Petrov 2019-03-17 16:10:16 -04:00
parent 5ff61f0a0f
commit b8fb704c8f

16
host.go
View File

@ -146,6 +146,14 @@ 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))
@ -162,14 +170,6 @@ func (h *Host) Connect(term *sshd.Terminal) {
m := message.ParseInput(line, user)
// Gross hack to override line echo in golang.org/x/crypto/ssh/terminal
// It needs to live before we render the resulting message.
term.Write([]byte{
27, '[', 'A', // Up
27, '[', '2', 'K', // Clear line
})
// May the gods have mercy on our souls.
if m, ok := m.(*message.CommandMsg); ok {
// Other messages render themselves by the room, commands we'll
// have to re-echo ourselves manually.