portlist: fix tests on Windows when not running as Administrator

Updates #50
This commit is contained in:
Brad Fitzpatrick 2020-10-28 09:18:18 -07:00
parent 7ac91c15bd
commit 4a92fc9dc5

View File

@ -8,6 +8,7 @@
"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")
}