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:
Brad Fitzpatrick
2025-04-01 04:01:00 -07:00
committed by Brad Fitzpatrick
parent 29c2bb1db6
commit 65c7a37bc6
6 changed files with 104 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ import (
"tailscale.com/derp/derphttp"
"tailscale.com/envknob"
"tailscale.com/hostinfo"
"tailscale.com/net/captivedetection"
"tailscale.com/net/dnscache"
"tailscale.com/net/neterror"
@@ -863,7 +864,7 @@ func (c *Client) GetReport(ctx context.Context, dm *tailcfg.DERPMap, opts *GetRe
c.curState = nil
}()
if runtime.GOOS == "js" || runtime.GOOS == "tamago" {
if runtime.GOOS == "js" || runtime.GOOS == "tamago" || (runtime.GOOS == "plan9" && hostinfo.IsInVM86()) {
if err := c.runHTTPOnlyChecks(ctx, last, rs, dm); err != nil {
return nil, err
}
@@ -1063,6 +1064,19 @@ func (c *Client) runHTTPOnlyChecks(ctx context.Context, last *Report, rs *report
regions = append(regions, dr)
}
}
if len(regions) == 1 && hostinfo.IsInVM86() {
// If we only have 1 region that's probably and we're in a
// network-limited v86 environment, don't actually probe it. Just fake
// some results.
rg := regions[0]
if len(rg.Nodes) > 0 {
node := rg.Nodes[0]
rs.addNodeLatency(node, netip.AddrPort{}, 999*time.Millisecond)
return nil
}
}
c.logf("running HTTP-only netcheck against %v regions", len(regions))
var wg sync.WaitGroup