From 0a6705f43e1d47a6a5c0a8bc21542c6541ad4ead Mon Sep 17 00:00:00 2001 From: Skyxim Date: Sun, 26 Feb 2023 12:39:53 +0800 Subject: [PATCH] fix: ip version prefer not working --- component/dialer/dialer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/component/dialer/dialer.go b/component/dialer/dialer.go index ab2fe047..1925e86c 100644 --- a/component/dialer/dialer.go +++ b/component/dialer/dialer.go @@ -136,10 +136,11 @@ func serialDualStackDialContext(ctx context.Context, network, address string, op if opt.prefer != 4 && opt.prefer != 6 { return serialDialContext(ctx, network, ips, port, opt) } + ipv4s, ipv6s := sortationAddr(ips) return dualStackDialContext( ctx, - func(ctx context.Context) (net.Conn, error) { return serialDialContext(ctx, network, ips, port, opt) }, - func(ctx context.Context) (net.Conn, error) { return serialDialContext(ctx, network, ips, port, opt) }, + func(ctx context.Context) (net.Conn, error) { return serialDialContext(ctx, network, ipv4s, port, opt) }, + func(ctx context.Context) (net.Conn, error) { return serialDialContext(ctx, network, ipv6s, port, opt) }, opt.prefer == 4) }