From df6462b50e5ba633602996ce3530ba8b98e70432 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Thu, 9 Nov 2017 13:14:12 +0100 Subject: [PATCH] Fix PR comments made by shirou --- net/net_openbsd.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/net_openbsd.go b/net/net_openbsd.go index 6437e7d..63caff5 100644 --- a/net/net_openbsd.go +++ b/net/net_openbsd.go @@ -97,7 +97,7 @@ func ParseNetstat(output string, mode string, } func IOCounters(pernic bool) ([]IOCountersStat, error) { - netstat, err := exec.LookPath("/usr/bin/netstat") + netstat, err := exec.LookPath("netstat") if err != nil { return nil, err } @@ -204,10 +204,13 @@ func parseNetstatAddr(local string, remote string, family uint32) (laddr Addr, r host := matches[1] port := matches[2] if host == "*" { - if family == syscall.AF_INET { + switch family { + case syscall.AF_INET: host = "0.0.0.0" - } else { + case syscall.AF_INET6: host = "::" + default: + return Addr{}, fmt.Errorf("unknown family, %d", family) } } lport, err := strconv.Atoi(port) @@ -241,7 +244,7 @@ func Connections(kind string) ([]ConnectionStat, error) { case "all": fallthrough case "inet": - + // nothing to add case "inet4": args = append(args, "-finet") case "inet6": @@ -262,7 +265,7 @@ func Connections(kind string) ([]ConnectionStat, error) { return ret, common.ErrNotImplementedError } - netstat, err := exec.LookPath("/usr/bin/netstat") + netstat, err := exec.LookPath("netstat") if err != nil { return nil, err }