New feature: Happy Eyeballs (RFC 8305) (#4667)

Closes https://github.com/XTLS/Xray-core/issues/4473
This commit is contained in:
patterniha 2025-06-07 16:50:06 +03:30 committed by GitHub
parent bfbccc2721
commit 97fdcb4228
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 417 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 == nil || sockopt.HappyEyeballs.TryDelayMs == 0 || sockopt.HappyEyeballs.MaxConcurrentTry == 0 || 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)
}
}