cmd/tsconnect, logpolicy: fixes for wasm_js.go

* updates to LocalBackend require metrics to be passed in which are now initialized
* os.MkdirTemp isn't supported in wasm/js so we simply return empty
  string for logger
* adds a UDP dialer which was missing and led to the dialer being
  incompletely initialized

Fixes #10454 and #8272

Signed-off-by: Christian <christian@devzero.io>
This commit is contained in:
Christian 2024-10-14 15:52:03 -07:00 committed by Brad Fitzpatrick
parent ff5f233c3a
commit 74dd24ce71
2 changed files with 7 additions and 0 deletions

View File

@ -108,6 +108,7 @@ func newIPN(jsConfig js.Value) map[string]any {
SetSubsystem: sys.Set,
ControlKnobs: sys.ControlKnobs(),
HealthTracker: sys.HealthTracker(),
Metrics: sys.UserMetricsRegistry(),
})
if err != nil {
log.Fatal(err)
@ -128,6 +129,9 @@ func newIPN(jsConfig js.Value) map[string]any {
dialer.NetstackDialTCP = func(ctx context.Context, dst netip.AddrPort) (net.Conn, error) {
return ns.DialContextTCP(ctx, dst)
}
dialer.NetstackDialUDP = func(ctx context.Context, dst netip.AddrPort) (net.Conn, error) {
return ns.DialContextUDP(ctx, dst)
}
sys.NetstackRouter.Set(true)
sys.Tun.Get().Start()

View File

@ -230,6 +230,9 @@ func LogsDir(logf logger.Logf) string {
logf("logpolicy: using $STATE_DIRECTORY, %q", systemdStateDir)
return systemdStateDir
}
case "js":
logf("logpolicy: no logs directory in the browser")
return ""
}
// Default to e.g. /var/lib/tailscale or /var/db/tailscale on Unix.