fix: ip version prefer not working

This commit is contained in:
Skyxim 2023-02-26 12:39:53 +08:00
parent 97e14337e3
commit 0a6705f43e

View file

@ -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)
}