refactor(forwarder): remove CreateForwardedTCPIPPayload method
SonarQube Scan / SonarQube Trigger (push) Successful in 2m32s

- OpenForwardedChannel now privately calls CreateForwardedTCPIPPayload
- Removed an unused function
This commit is contained in:
2026-01-25 20:49:12 +07:00
parent 21b551a66d
commit f1d20905d0
6 changed files with 20 additions and 54 deletions
+2 -4
View File
@@ -18,8 +18,7 @@ type tcp struct {
}
type Forwarder interface {
CreateForwardedTCPIPPayload(origin net.Addr) []byte
OpenForwardedChannel(ctx context.Context, payload []byte) (ssh.Channel, <-chan *ssh.Request, error)
OpenForwardedChannel(ctx context.Context, origin net.Addr) (ssh.Channel, <-chan *ssh.Request, error)
HandleConnection(dst io.ReadWriter, src ssh.Channel)
}
@@ -55,10 +54,9 @@ func (tt *tcp) handleTcp(conn net.Conn) {
log.Printf("Failed to close connection: %v", err)
}
}()
payload := tt.forwarder.CreateForwardedTCPIPPayload(conn.RemoteAddr())
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
channel, reqs, err := tt.forwarder.OpenForwardedChannel(ctx, payload)
channel, reqs, err := tt.forwarder.OpenForwardedChannel(ctx, conn.RemoteAddr())
if err != nil {
log.Printf("Failed to open forwarded-tcpip channel: %v", err)
return