|
|
@ -13,12 +13,22 @@ import (
|
|
|
|
exec "tailscale.com/tempfork/osexec"
|
|
|
|
exec "tailscale.com/tempfork/osexec"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var osHideWindow func(*exec.Cmd) // non-nil on Windows; see portlist_windows.go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// hideWindow returns c. On Windows it first sets SysProcAttr.HideWindow.
|
|
|
|
|
|
|
|
func hideWindow(c *exec.Cmd) *exec.Cmd {
|
|
|
|
|
|
|
|
if osHideWindow != nil {
|
|
|
|
|
|
|
|
osHideWindow(c)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return c
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func listPortsNetstat(arg string) (List, error) {
|
|
|
|
func listPortsNetstat(arg string) (List, error) {
|
|
|
|
exe, err := exec.LookPath("netstat")
|
|
|
|
exe, err := exec.LookPath("netstat")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("netstat: lookup: %v", err)
|
|
|
|
return nil, fmt.Errorf("netstat: lookup: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
output, err := exec.Command(exe, arg).Output()
|
|
|
|
output, err := hideWindow(exec.Command(exe, arg)).Output()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
xe, ok := err.(*exec.ExitError)
|
|
|
|
xe, ok := err.(*exec.ExitError)
|
|
|
|
stderr := ""
|
|
|
|
stderr := ""
|
|
|
|