New feature: Happy Eyeballs (RFC 8305)

This commit is contained in:
patterniha 2025-04-29 14:39:02 +03:30
parent aa4134f4a6
commit 4be238a5f3
6 changed files with 413 additions and 99 deletions

View file

@ -255,9 +255,11 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig
if sockopt.DomainStrategy.forceIP() {
return nil, err
}
} else {
} else if !sockopt.HappyEyeballs.Enabled || len(ips) < 2 || len(sockopt.DialerProxy) > 0 || dest.Network != net.Network_TCP {
dest.Address = net.IPAddress(ips[dice.Roll(len(ips))])
errors.LogInfo(ctx, "replace destination with "+dest.String())
} else {
return TcpRaceDial(ctx, src, ips, dest.Port, sockopt)
}
}