net/dns: make WSL network configuration opt-in for now

Tailscale seems to be breaking WSL configurations lately.  Until we
understand what changed, turn off Tailscale's involvement by default
and make it opt-in.

Updates #2815

Change-Id: I9977801f8debec7d489d97761f74000a4a33f71b
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/3709/head
Brad Fitzpatrick 2022-01-09 21:14:50 -08:00 committed by Brad Fitzpatrick
parent 66f6efa8cb
commit 8df3fa4638
1 changed files with 13 additions and 7 deletions

View File

@ -7,8 +7,10 @@ package dns
import ( import (
"errors" "errors"
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"sort" "sort"
"strconv"
"strings" "strings"
"syscall" "syscall"
"time" "time"
@ -34,6 +36,8 @@ const (
versionKey = `SOFTWARE\Microsoft\Windows NT\CurrentVersion` versionKey = `SOFTWARE\Microsoft\Windows NT\CurrentVersion`
) )
var configureWSL, _ = strconv.ParseBool(os.Getenv("TS_DEBUG_CONFIGURE_WSL"))
type windowsManager struct { type windowsManager struct {
logf logger.Logf logf logger.Logf
guid string guid string
@ -307,13 +311,15 @@ func (m windowsManager) SetDNS(cfg OSConfig) error {
// On initial setup of WSL, the restart caused by --shutdown is slow, // On initial setup of WSL, the restart caused by --shutdown is slow,
// so we do it out-of-line. // so we do it out-of-line.
go func() { if configureWSL {
if err := m.wslManager.SetDNS(cfg); err != nil { go func() {
m.logf("WSL SetDNS: %v", err) // continue if err := m.wslManager.SetDNS(cfg); err != nil {
} else { m.logf("WSL SetDNS: %v", err) // continue
m.logf("WSL SetDNS: success") } else {
} m.logf("WSL SetDNS: success")
}() }
}()
}
return nil return nil
} }