mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-06 12:52:00 +00:00
wgengine/magicsock: prefer IPv6 transport if roughly equivalent latency
Fixes #1566 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
e2b3d9aa5f
commit
c99f260e40
@@ -3670,6 +3670,17 @@ func betterAddr(a, b addrLatency) bool {
|
||||
if a.IsZero() {
|
||||
return false
|
||||
}
|
||||
if a.IP.Is6() && b.IP.Is4() {
|
||||
// Prefer IPv6 for being a bit more robust, as long as
|
||||
// the latencies are roughly equivalent.
|
||||
if a.latency/10*9 < b.latency {
|
||||
return true
|
||||
}
|
||||
} else if a.IP.Is4() && b.IP.Is6() {
|
||||
if betterAddr(b, a) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return a.latency < b.latency
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user