From 83788bf9c21ebe6ce9d13542b5a4946e7b1c0071 Mon Sep 17 00:00:00 2001 From: Erik Pellizzon Date: Fri, 20 Dec 2024 17:01:47 +0100 Subject: [PATCH] Remove copy warning that adds no information --- https.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/https.go b/https.go index 654423f5..50db89ca 100644 --- a/https.go +++ b/https.go @@ -137,18 +137,17 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request targetTCP, targetOK := targetSiteCon.(halfClosable) proxyClientTCP, clientOK := proxyClient.(halfClosable) if targetOK && clientOK { - go copyAndClose(ctx, targetTCP, proxyClientTCP) - go copyAndClose(ctx, proxyClientTCP, targetTCP) + go copyAndClose(targetTCP, proxyClientTCP) + go copyAndClose(proxyClientTCP, targetTCP) } else { go func() { var wg sync.WaitGroup wg.Add(2) - go copyOrWarn(ctx, targetSiteCon, proxyClient, &wg) - go copyOrWarn(ctx, proxyClient, targetSiteCon, &wg) + go copyOrWarn(targetSiteCon, proxyClient, &wg) + go copyOrWarn(proxyClient, targetSiteCon, &wg) wg.Wait() proxyClient.Close() targetSiteCon.Close() - }() } @@ -390,18 +389,13 @@ func httpError(w io.WriteCloser, ctx *ProxyCtx, err error) { } } -func copyOrWarn(ctx *ProxyCtx, dst io.Writer, src io.Reader, wg *sync.WaitGroup) { - if _, err := io.Copy(dst, src); err != nil { - ctx.Warnf("Error copying to client: %s", err) - } +func copyOrWarn(dst io.Writer, src io.Reader, wg *sync.WaitGroup) { + _, _ = io.Copy(dst, src) wg.Done() } -func copyAndClose(ctx *ProxyCtx, dst, src halfClosable) { - if _, err := io.Copy(dst, src); err != nil { - ctx.Warnf("Error copying to client: %s", err) - } - +func copyAndClose(dst, src halfClosable) { + _, _ = io.Copy(dst, src) dst.CloseWrite() src.CloseRead() }