From a8e2cceefdcd0387a4bb54efcc48f2aeb4b1a07b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 22 Oct 2021 09:08:15 -0700 Subject: [PATCH] net/netcheck: hard-code preferred DERP region 900 on js/wasm for now See TODO in code. Updates #3157 Change-Id: I3a14dd2cf51d3c21336bb357af5abc362a079ff4 Signed-off-by: Brad Fitzpatrick --- net/netcheck/netcheck.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/netcheck/netcheck.go b/net/netcheck/netcheck.go index f470a73af..fc2f8ee12 100644 --- a/net/netcheck/netcheck.go +++ b/net/netcheck/netcheck.go @@ -17,6 +17,7 @@ import ( "net" "net/http" "os" + "runtime" "sort" "strconv" "sync" @@ -737,6 +738,16 @@ func (c *Client) udpBindAddr() string { // // It may not be called concurrently with itself. func (c *Client) GetReport(ctx context.Context, dm *tailcfg.DERPMap) (*Report, error) { + if runtime.GOOS == "js" { + // TODO(bradfitz): do a real js/wasm netcheck, once + // the WebSocket-capable DERPs are rolled out. For now + // you need to be running in a tailnet with Region 900 + // derper available that supports webassembly. + return &Report{ + PreferredDERP: 900, + }, nil + } + // Mask user context with ours that we guarantee to cancel so // we can depend on it being closed in goroutines later. // (User ctx might be context.Background, etc)