From efca370bfc3abdd0b6ce2d9c2886af2eaa5bc48d Mon Sep 17 00:00:00 2001 From: Kuzz007 Date: Sun, 2 Aug 2026 14:49:53 +0300 Subject: [PATCH] fix(amneziawg): satisfy golangci-lint in relay.go errcheck: explicitly discard io.Copy's error in the two fire-and-forget relay goroutines -- a copy error there just means the connection closed, which is the expected/normal way this loop ends, not something to handle further. noctx: net.DialTimeout must not be called per this repo's lint config; use (*net.Dialer).DialContext with Timeout set instead, same as the rest of the codebase already does. Co-Authored-By: Claude Sonnet 5 --- internal/amneziawgnet/relay.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/amneziawgnet/relay.go b/internal/amneziawgnet/relay.go index f17b42995..33f3b7662 100644 --- a/internal/amneziawgnet/relay.go +++ b/internal/amneziawgnet/relay.go @@ -7,6 +7,7 @@ package amneziawgnet import ( + "context" "encoding/binary" "encoding/json" "fmt" @@ -80,8 +81,8 @@ func (r SocksRelay) RelayTCP(conn *gonet.TCPConn, email string, dest netip.AddrP defer upstream.Close() done := make(chan struct{}, 2) - go func() { io.Copy(upstream, conn); done <- struct{}{} }() - go func() { io.Copy(conn, upstream); done <- struct{}{} }() + go func() { _, _ = io.Copy(upstream, conn); done <- struct{}{} }() + go func() { _, _ = io.Copy(conn, upstream); done <- struct{}{} }() <-done } @@ -101,7 +102,8 @@ type socks5UDPSession struct { // types, not reusable as a standalone dialer -- so this is a small, direct, // from-the-RFC implementation rather than an existing library call. func newSocks5UDPSession(addr, user, password string) (*socks5UDPSession, error) { - ctrl, err := net.DialTimeout("tcp", addr, 5*time.Second) + dialer := net.Dialer{Timeout: 5 * time.Second} + ctrl, err := dialer.DialContext(context.Background(), "tcp", addr) if err != nil { return nil, fmt.Errorf("amneziawgnet: dial SOCKS5 control connection: %w", err) }