2017-09-11 09:59:00 +00:00
|
|
|
package gateway
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func DiscoverGateway() (ip net.IP, iface string, err error) {
|
|
|
|
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 parseBSDSolarisNetstat(output)
|
|
|
|
}
|