summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/shazow/ssh-chat/sshd/net.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/shazow/ssh-chat/sshd/net.go')
-rw-r--r--vendor/github.com/shazow/ssh-chat/sshd/net.go7
1 files changed, 7 insertions, 0 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 {