From 269196c94f3ca7b2d8fb9efe001295bc161d6948 Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Wed, 18 Aug 2021 15:12:47 +0000 Subject: [PATCH] support existing connections for port forwarding --- port_forwarder.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/port_forwarder.go b/port_forwarder.go index 06c164e8d..e6eedf16c 100644 --- a/port_forwarder.go +++ b/port_forwarder.go @@ -54,7 +54,12 @@ func (l *PortForwarder) Start(ctx context.Context) error { return nil } -func (l *PortForwarder) handleConnection(ctx context.Context, conn net.Conn) { +func (l *PortForwarder) StartWithConn(ctx context.Context, conn io.ReadWriteCloser) error { + go l.handleConnection(ctx, conn) + return <-l.errCh +} + +func (l *PortForwarder) handleConnection(ctx context.Context, conn io.ReadWriteCloser) { channel, err := l.client.openStreamingChannel(ctx, l.server.streamName, l.server.streamCondition) if err != nil { l.errCh <- fmt.Errorf("error opening streaming channel for new connection: %v", err)