diff options
author | Wim <wim@42.be> | 2020-03-08 23:55:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-08 23:55:09 +0100 |
commit | 6b4b19194ec40c79569bc692a6557e78f338ded9 (patch) | |
tree | 72f52510f7388f2575859e5be3d2b75970f979f2 /vendor/github.com/shazow/ssh-chat/sshd | |
parent | 9785edd26366be8eb11c2435f50f90a5c8eea7fc (diff) | |
download | matterbridge-msglm-6b4b19194ec40c79569bc692a6557e78f338ded9.tar.gz matterbridge-msglm-6b4b19194ec40c79569bc692a6557e78f338ded9.tar.bz2 matterbridge-msglm-6b4b19194ec40c79569bc692a6557e78f338ded9.zip |
Update vendor shazow/ssh-chat (#1029)
Diffstat (limited to 'vendor/github.com/shazow/ssh-chat/sshd')
4 files changed, 30 insertions, 3 deletions
diff --git a/vendor/github.com/shazow/ssh-chat/sshd/net.go b/vendor/github.com/shazow/ssh-chat/sshd/net.go index 8305696b..678454ba 100644 --- a/vendor/github.com/shazow/ssh-chat/sshd/net.go +++ b/vendor/github.com/shazow/ssh-chat/sshd/net.go @@ -2,6 +2,7 @@ package sshd import ( "net" + "time" "github.com/shazow/rateio" "golang.org/x/crypto/ssh" @@ -32,6 +33,12 @@ func (l *SSHListener) handleConn(conn net.Conn) (*Terminal, error) { conn = ReadLimitConn(conn, l.RateLimit()) } + // If the connection doesn't write anything back for too long before we get + // a valid session, it should be dropped. + var handleTimeout = 20 * time.Second + conn.SetReadDeadline(time.Now().Add(handleTimeout)) + defer conn.SetReadDeadline(time.Time{}) + // Upgrade TCP connection to SSH connection sshConn, channels, requests, err := ssh.NewServerConn(conn, l.config) if err != nil { diff --git a/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go b/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go index 690937e6..d6650bb1 100644 --- a/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go +++ b/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go @@ -129,6 +129,8 @@ const ( keyRight keyAltLeft keyAltRight + keyAltF + keyAltB keyHome keyEnd keyDeleteWord @@ -155,8 +157,12 @@ func bytesToKey(b []byte, pasteActive bool) (rune, []byte) { switch b[0] { case 1: // ^A return keyHome, b[1:] + case 2: // ^B + return keyLeft, b[1:] case 5: // ^E return keyEnd, b[1:] + case 6: // ^F + return keyRight, b[1:] case 8: // ^H return keyBackspace, b[1:] case 11: // ^K @@ -206,6 +212,15 @@ func bytesToKey(b []byte, pasteActive bool) (rune, []byte) { } } + if !pasteActive && len(b) >= 2 && b[0] == keyEscape { + switch b[1] { + case 'f': + return keyAltF, b[2:] + case 'b': + return keyAltB, b[2:] + } + } + if !pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteStart) { return keyPasteStart, b[6:] } @@ -467,10 +482,14 @@ func (t *Terminal) handleKey(key rune) (line string, ok bool) { return } t.eraseNPreviousChars(1) + case keyAltB: + fallthrough case keyAltLeft: // move left by a word. t.pos -= t.countToLeftWord() t.moveCursorToPos(t.pos) + case keyAltF: + fallthrough case keyAltRight: // move right by a word. t.pos += t.countToRightWord() diff --git a/vendor/github.com/shazow/ssh-chat/sshd/terminal/util.go b/vendor/github.com/shazow/ssh-chat/sshd/terminal/util.go index 39110408..e553f7e8 100644 --- a/vendor/github.com/shazow/ssh-chat/sshd/terminal/util.go +++ b/vendor/github.com/shazow/ssh-chat/sshd/terminal/util.go @@ -14,7 +14,7 @@ // panic(err) // } // defer terminal.Restore(0, oldState) -package terminal // import "golang.org/x/crypto/ssh/terminal" +package terminal import ( "golang.org/x/sys/unix" diff --git a/vendor/github.com/shazow/ssh-chat/sshd/terminal/util_solaris.go b/vendor/github.com/shazow/ssh-chat/sshd/terminal/util_solaris.go index 3d5f06a9..7b6b6fb3 100644 --- a/vendor/github.com/shazow/ssh-chat/sshd/terminal/util_solaris.go +++ b/vendor/github.com/shazow/ssh-chat/sshd/terminal/util_solaris.go @@ -4,12 +4,13 @@ // +build solaris -package terminal // import "golang.org/x/crypto/ssh/terminal" +package terminal import ( - "golang.org/x/sys/unix" "io" "syscall" + + "golang.org/x/sys/unix" ) // State contains the state of a terminal. |