test(stream): add unit tests for stream behavior
SonarQube Scan / SonarQube Trigger (push) Successful in 1m39s

- Fix duplicating EOF error when closing SSH connection
- Add new SessionStatusCLOSED type
This commit is contained in:
2026-01-22 21:04:05 +07:00
parent d7e1f3fa63
commit 7159300fa2
10 changed files with 775 additions and 117 deletions
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"log"
"net"
"time"
@@ -85,7 +86,7 @@ func (s *server) handleConnection(conn net.Conn) {
defer func(sshConn *ssh.ServerConn) {
err = sshConn.Close()
if err != nil && !errors.Is(err, net.ErrClosed) {
if err != nil && !errors.Is(err, net.ErrClosed) && !errors.Is(err, io.EOF) {
log.Printf("failed to close SSH server: %v", err)
}
}(sshConn)
@@ -101,7 +102,7 @@ func (s *server) handleConnection(conn net.Conn) {
sshSession := session.New(s.randomizer, s.config, sshConn, forwardingReqs, chans, s.sessionRegistry, s.portRegistry, user)
err = sshSession.Start()
if err != nil {
log.Printf("SSH session ended with error: %v", err)
log.Printf("SSH session ended with error: %s", err.Error())
return
}
return