diff --git a/internal/socks5/udp_router.go b/internal/socks5/udp_router.go index f8e739d7..e4ffef4a 100644 --- a/internal/socks5/udp_router.go +++ b/internal/socks5/udp_router.go @@ -336,11 +336,14 @@ func (r *udpRouter) writeClientPacketToDestination(ctx context.Context, return fmt.Errorf("splitting destination host and port: %w", err) } - if _, err := netip.ParseAddr(destination); err != nil { // domain name + if _, err := netip.ParseAddr(host); err != nil { // domain name addrs, err := net.DefaultResolver.LookupHost(ctx, host) if err != nil { return fmt.Errorf("resolving destination host: %w", err) } + if len(addrs) == 0 { + return fmt.Errorf("resolving destination host: no addresses found for %q", host) + } destination = net.JoinHostPort(addrs[0], portStr) }