From 9310713bfbf5a901ab4b28cde06644acbf3625a5 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 20 Oct 2021 09:41:36 -0700 Subject: [PATCH] all: fix some js/wasm compilation issues Change-Id: I05a3a4835e225a1e413ec3540a7c7e4a2d477084 Signed-off-by: Brad Fitzpatrick --- paths/paths_js.go | 9 +++++++++ paths/paths_unix.go | 4 ++-- portlist/portlist_js.go | 17 +++++++++++++++++ portlist/portlist_other.go | 4 ++-- .../{rusage_windows.go => rusage_stub.go} | 3 +++ .../{rusage_nowindows.go => rusage_syscall.go} | 4 ++-- wgengine/router/router_default.go | 4 ++-- 7 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 paths/paths_js.go create mode 100644 portlist/portlist_js.go rename types/logger/{rusage_windows.go => rusage_stub.go} (86%) rename types/logger/{rusage_nowindows.go => rusage_syscall.go} (92%) diff --git a/paths/paths_js.go b/paths/paths_js.go new file mode 100644 index 000000000..1908254e7 --- /dev/null +++ b/paths/paths_js.go @@ -0,0 +1,9 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package paths + +func ensureStateDirPerms(dirPath string) error { + return nil +} diff --git a/paths/paths_unix.go b/paths/paths_unix.go index fa95c783e..269abea0e 100644 --- a/paths/paths_unix.go +++ b/paths/paths_unix.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !windows -// +build !windows +//go:build !windows && !js +// +build !windows,!js package paths diff --git a/portlist/portlist_js.go b/portlist/portlist_js.go new file mode 100644 index 000000000..6e6b18ed2 --- /dev/null +++ b/portlist/portlist_js.go @@ -0,0 +1,17 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package portlist + +import "time" + +const pollInterval = 365 * 24 * time.Hour + +func listPorts() (List, error) { + return nil, nil +} + +func addProcesses(pl []Port) ([]Port, error) { + return pl, nil +} diff --git a/portlist/portlist_other.go b/portlist/portlist_other.go index 84193f623..f18a95d2c 100644 --- a/portlist/portlist_other.go +++ b/portlist/portlist_other.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !linux && !windows && !darwin -// +build !linux,!windows,!darwin +//go:build !linux && !windows && !darwin && !js +// +build !linux,!windows,!darwin,!js package portlist diff --git a/types/logger/rusage_windows.go b/types/logger/rusage_stub.go similarity index 86% rename from types/logger/rusage_windows.go rename to types/logger/rusage_stub.go index ec5cf5513..3a9202d1c 100644 --- a/types/logger/rusage_windows.go +++ b/types/logger/rusage_stub.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows || js +// +build windows js + package logger func rusageMaxRSS() float64 { diff --git a/types/logger/rusage_nowindows.go b/types/logger/rusage_syscall.go similarity index 92% rename from types/logger/rusage_nowindows.go rename to types/logger/rusage_syscall.go index bb82bab88..b767718ac 100644 --- a/types/logger/rusage_nowindows.go +++ b/types/logger/rusage_syscall.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !windows -// +build !windows +//go:build !windows && !js +// +build !windows,!js package logger diff --git a/wgengine/router/router_default.go b/wgengine/router/router_default.go index 4e6a724ba..9f2e9aa46 100644 --- a/wgengine/router/router_default.go +++ b/wgengine/router/router_default.go @@ -16,8 +16,8 @@ import ( "tailscale.com/wgengine/monitor" ) -func newUserspaceRouter(logf logger.Logf, tunname string, tunDev tun.Device, linkMon *monitor.Mon) Router { - panic(fmt.Sprintf("unsupported OS %q", runtime.GOOS)) +func newUserspaceRouter(logf logger.Logf, tunDev tun.Device, linkMon *monitor.Mon) (Router, error) { + return nil, fmt.Errorf("unsupported OS %q", runtime.GOOS) } func cleanup(logf logger.Logf, interfaceName string) {