mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
portlist: use windows OpenCurrentProcessToken, not GetCurrentProcessToken
The latter only works on Windows 8+. Also add a TODO to get do this all more efficiently. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
e619296ece
commit
c0befee188
@ -16,11 +16,21 @@
|
||||
const pollInterval = 5 * time.Second
|
||||
|
||||
func listPorts() (List, error) {
|
||||
// TODO(bradfitz): stop shelling out to netstat and use the
|
||||
// net/netstat package instead. When doing so, be sure to filter
|
||||
// out all of 127.0.0.0/8 and not just 127.0.0.1.
|
||||
return listPortsNetstat("-na")
|
||||
}
|
||||
|
||||
func addProcesses(pl []Port) ([]Port, error) {
|
||||
if t := windows.GetCurrentProcessToken(); !t.IsElevated() {
|
||||
// OpenCurrentProcessToken instead of GetCurrentProcessToken,
|
||||
// as GetCurrentProcessToken only works on Windows 8+.
|
||||
tok, err := windows.OpenCurrentProcessToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer tok.Close()
|
||||
if !tok.IsElevated() {
|
||||
return listPortsNetstat("-na")
|
||||
}
|
||||
return listPortsNetstat("-nab")
|
||||
|
Loading…
Reference in New Issue
Block a user