From efe519cb7af8015a0747ac20d91877627b21b8cc Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Thu, 9 Sep 2021 20:11:45 +0000 Subject: [PATCH] comments + fix Forward method --- port_forwarder.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/port_forwarder.go b/port_forwarder.go index e8649c693..be191c211 100644 --- a/port_forwarder.go +++ b/port_forwarder.go @@ -80,9 +80,7 @@ func (fwd *PortForwarder) Forward(ctx context.Context, conn io.ReadWriteCloser) // Create buffered channel so that send doesn't get stuck after context cancellation. errc := make(chan error, 1) go func() { - if err := fwd.handleConnection(ctx, id, conn); err != nil { - errc <- err - } + errc <- fwd.handleConnection(ctx, id, conn) }() return awaitError(ctx, errc) } @@ -131,7 +129,9 @@ func (fwd *PortForwarder) handleConnection(ctx context.Context, id channelID, co go copyConn(conn, channel) go copyConn(channel, conn) - // wait until context is cancelled or both copies are done + // Wait until context is cancelled or both copies are done. + // Discard errors from io.Copy; they should not cause (e.g.) ForwardToListener to fail. + // TODO: how can we proxy errors from Copy so that each peer can distinguish an error from a short file? for i := 0; ; { select { case <-ctx.Done():