From 60bee62c33715ca0c72e5508908a71885432ac96 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 4 Jun 2026 19:17:33 +0200 Subject: [PATCH] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- internal/socks5/socks5.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/socks5/socks5.go b/internal/socks5/socks5.go index 2dc66ed4..c7595629 100644 --- a/internal/socks5/socks5.go +++ b/internal/socks5/socks5.go @@ -211,13 +211,6 @@ func (c *socksConn) handleUDPAssociateRequest(ctx context.Context, return fmt.Errorf("getting udp association addresses: %w", err) } - err = c.encodeSuccessResponse(c.clientConn, socksVersion, succeeded, - bindAddrType, bindAddress, bindPort) - if err != nil { - c.encodeFailedResponse(c.clientConn, socksVersion, generalServerFailure) - return fmt.Errorf("writing successful %s response: %w", udpAssociate, err) - } - association, err := c.udpRouter.registerAssociation(c.clientConn, expectedAddrPort) if err != nil { c.encodeFailedResponse(c.clientConn, socksVersion, generalServerFailure) @@ -225,6 +218,13 @@ func (c *socksConn) handleUDPAssociateRequest(ctx context.Context, } defer c.udpRouter.unregisterAssociation(association) + err = c.encodeSuccessResponse(c.clientConn, socksVersion, succeeded, + bindAddrType, bindAddress, bindPort) + if err != nil { + c.encodeFailedResponse(c.clientConn, socksVersion, generalServerFailure) + return fmt.Errorf("writing successful %s response: %w", udpAssociate, err) + } + associationCtx, associationCancel := context.WithCancel(ctx) defer associationCancel()