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 <noreply@anthropic.com>
This commit is contained in:
Kuzz007
2026-08-02 14:49:53 +03:00
parent 124665c5ef
commit efca370bfc
+5 -3
View File
@@ -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)
}