fix: ensure SSH connections close on client disconnect
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 4m20s
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 4m20s
This commit is contained in:
@ -11,7 +11,11 @@ func (s *Server) handleConnection(conn net.Conn) {
|
||||
sshConn, chans, forwardingReqs, err := ssh.NewServerConn(conn, s.Config)
|
||||
if err != nil {
|
||||
log.Printf("failed to establish SSH connection: %v", err)
|
||||
conn.Close()
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
log.Printf("failed to close SSH connection: %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -21,5 +25,12 @@ func (s *Server) handleConnection(conn net.Conn) {
|
||||
for ch := range chans {
|
||||
newSession.ChannelChan <- ch
|
||||
}
|
||||
|
||||
defer func(newSession *session.Session) {
|
||||
err := newSession.Close()
|
||||
if err != nil {
|
||||
log.Printf("failed to close session: %v", err)
|
||||
}
|
||||
}(newSession)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user