mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-21 02:17:36 +00:00
all: use network less when running in v86 emulator
Updates #5794 Change-Id: I1d8b005a1696835c9062545f87b7bab643cfc44d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
29c2bb1db6
commit
65c7a37bc6
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"tailscale.com/control/controlknobs"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/hostinfo"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstime"
|
||||
"tailscale.com/types/key"
|
||||
@@ -308,6 +309,31 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
// In the copy/v86 wasm environment with limited networking, if the
|
||||
// control plane didn't pick our DERP home for us, do it ourselves and
|
||||
// mark all but the lowest region as NoMeasureNoHome. For prod, this
|
||||
// will be Region 1, NYC, a compromise between the US and Europe. But
|
||||
// really the control plane should pick this. This is only a fallback.
|
||||
if hostinfo.IsInVM86() {
|
||||
numCanMeasure := 0
|
||||
lowest := 0
|
||||
for rid, r := range dm.Regions {
|
||||
if !r.NoMeasureNoHome {
|
||||
numCanMeasure++
|
||||
if lowest == 0 || rid < lowest {
|
||||
lowest = rid
|
||||
}
|
||||
}
|
||||
}
|
||||
if numCanMeasure > 1 {
|
||||
for rid, r := range dm.Regions {
|
||||
if rid != lowest {
|
||||
r.NoMeasureNoHome = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Zero-valued fields in a DERPMap mean that we're not changing
|
||||
// anything and are using the previous value(s).
|
||||
if ldm := ms.lastDERPMap; ldm != nil {
|
||||
|
Reference in New Issue
Block a user