refactor: remove duplicate channel management helpers from HTTP handler
SonarQube Scan / SonarQube Trigger (push) Successful in 2m12s

This commit is contained in:
2026-01-25 13:47:57 +07:00
parent 2b488a5ab5
commit 8b44e4db4e
6 changed files with 43 additions and 139 deletions
+6 -2
View File
@@ -1,11 +1,13 @@
package transport
import (
"context"
"errors"
"fmt"
"io"
"log"
"net"
"time"
"golang.org/x/crypto/ssh"
)
@@ -17,7 +19,7 @@ type tcp struct {
type Forwarder interface {
CreateForwardedTCPIPPayload(origin net.Addr) []byte
OpenForwardedChannel(payload []byte) (ssh.Channel, <-chan *ssh.Request, error)
OpenForwardedChannel(ctx context.Context, payload []byte) (ssh.Channel, <-chan *ssh.Request, error)
HandleConnection(dst io.ReadWriter, src ssh.Channel)
}
@@ -54,7 +56,9 @@ func (tt *tcp) handleTcp(conn net.Conn) {
}
}()
payload := tt.forwarder.CreateForwardedTCPIPPayload(conn.RemoteAddr())
channel, reqs, err := tt.forwarder.OpenForwardedChannel(payload)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
channel, reqs, err := tt.forwarder.OpenForwardedChannel(ctx, payload)
if err != nil {
log.Printf("Failed to open forwarded-tcpip channel: %v", err)
return