From 4a92fc9dc515886e9598785fcb4b53c15963797a Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 28 Oct 2020 09:18:18 -0700 Subject: [PATCH] portlist: fix tests on Windows when not running as Administrator Updates #50 --- portlist/portlist_windows.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/portlist/portlist_windows.go b/portlist/portlist_windows.go index 1d38fe5e9..ee6e6cf14 100644 --- a/portlist/portlist_windows.go +++ b/portlist/portlist_windows.go @@ -8,6 +8,7 @@ import ( "syscall" "time" + "golang.org/x/sys/windows" exec "tailscale.com/tempfork/osexec" ) @@ -19,6 +20,9 @@ func listPorts() (List, error) { } func addProcesses(pl []Port) ([]Port, error) { + if t := windows.GetCurrentProcessToken(); !t.IsElevated() { + return listPortsNetstat("-na") + } return listPortsNetstat("-nab") }