gateway_windows -> chcp 437

This commit is contained in:
insanity 2018-08-23 16:32:40 +09:00
parent dd4f956c58
commit bf5ffd1c38
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Gopkg.toml example # Gopkg.toml example
# #
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation. # for detailed Gopkg.toml documentation.
# #
# required = ["github.com/user/thing/cmd/thing"] # required = ["github.com/user/thing/cmd/thing"]

View File

@ -1,13 +1,17 @@
package gateway package gateway
import ( import (
"log"
"net" "net"
"os/exec" "os/exec"
) )
func DiscoverGateway() (ip net.IP, iface string, err error) { func DiscoverGateway() (ip net.IP, iface string, err error) {
routeCmd := exec.Command("route", "print", "0.0.0.0") output, err := exec.Command("cmd.exe", "/C", "chcp 437 && route print 0.0.0.0").CombinedOutput()
output, err := routeCmd.CombinedOutput() if err != nil {
panic(err)
}
log.Println(string(output))
if err != nil { if err != nil {
return nil, "", err return nil, "", err
} }