2018-04-03 08:37:26 +00:00
|
|
|
package gateway
|
|
|
|
|
|
|
|
import (
|
2018-08-23 07:32:40 +00:00
|
|
|
"log"
|
2018-04-03 08:37:26 +00:00
|
|
|
"net"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func DiscoverGateway() (ip net.IP, iface string, err error) {
|
2018-08-23 07:32:40 +00:00
|
|
|
output, err := exec.Command("cmd.exe", "/C", "chcp 437 && route print 0.0.0.0").CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
log.Println(string(output))
|
2018-04-03 08:37:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return parseWindowsRoutePrint(output)
|
|
|
|
}
|