support existing connections for port forwarding

This commit is contained in:
Jose Garcia 2021-08-18 15:12:47 +00:00 committed by GitHub
parent 79111d85ac
commit 269196c94f

View file

@ -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)