2018-08-22 05:50:46 +00:00
|
|
|
package gateway
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func DiscoverGateway() (ip net.IP, iface string, err error) {
|
2018-08-23 09:29:29 +00:00
|
|
|
output, err := exec.Command("cmd.exe", "/C", "chcp 437 && route print 0.0.0.0").CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-08-22 05:50:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return parseWindowsRoutePrint(output)
|
|
|
|
}
|