util/net/gateway/gateway_darwin.go

17 lines
276 B
Go
Raw Normal View History

2017-09-11 09:59:00 +00:00
package gateway
import (
"net"
"os/exec"
)
2017-12-01 15:43:09 +00:00
func DiscoverGateway() (ip net.IP, iface string, err error) {
2017-09-11 09:59:00 +00:00
routeCmd := exec.Command("netstat", "-rn")
output, err := routeCmd.CombinedOutput()
if err != nil {
2017-12-01 15:43:09 +00:00
return nil, "", err
2017-09-11 09:59:00 +00:00
}
return parseDarwinRouteGet(output)
}