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)