mirror of https://github.com/status-im/consul.git
Update Windows support.
This commit is contained in:
parent
5fc97b997d
commit
594e75a301
|
@ -1,9 +1,6 @@
|
||||||
package sockaddr
|
package sockaddr
|
||||||
|
|
||||||
import (
|
import "os/exec"
|
||||||
"errors"
|
|
||||||
"os/exec"
|
|
||||||
)
|
|
||||||
|
|
||||||
// defaultWindowsIfNameCmd is the comamnd to run on Windows to get the default
|
// defaultWindowsIfNameCmd is the comamnd to run on Windows to get the default
|
||||||
// interface.
|
// interface.
|
||||||
|
@ -20,23 +17,22 @@ func defaultWindowsIPConfigCmd() []string {
|
||||||
// getDefaultIfName is a Windows-specific function for extracting the name of
|
// getDefaultIfName is a Windows-specific function for extracting the name of
|
||||||
// the interface from `netstat -rn` and `ipconfig`.
|
// the interface from `netstat -rn` and `ipconfig`.
|
||||||
func getDefaultIfName() (string, error) {
|
func getDefaultIfName() (string, error) {
|
||||||
ipAddr, err := getWindowsIPOnDefaultRoute()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return ipAddr, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getWindowsIPOnDefaultRoute() (string, error) {
|
|
||||||
var cmd []string = defaultWindowsIfNameCmd()
|
var cmd []string = defaultWindowsIfNameCmd()
|
||||||
out, err := exec.Command(cmd[0], cmd[1:]...).Output()
|
ifNameOut, err := exec.Command(cmd[0], cmd[1:]...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultIPAddr string
|
cmd = defaultWindowsIPConfigCmd()
|
||||||
if defaultIPAddr, err = parseDefaultIPAddrWindowsRoute(string(out)); err != nil {
|
ipconfigOut, err := exec.Command(cmd[0], cmd[1:]...).Output()
|
||||||
return "", errors.New("No IP on default route found")
|
if err != nil {
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
return defaultIPAddr, nil
|
|
||||||
|
ifName, err := parseDefaultIfNameWindows(string(ifNameOut), string(ipconfigOut))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ifName, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,10 +420,10 @@
|
||||||
"revisionTime": "2016-09-30T03:51:02Z"
|
"revisionTime": "2016-09-30T03:51:02Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "wGgPqc+2Lwn6qbDjM15SLKktd+Y=",
|
"checksumSHA1": "LmCRW89WaBzau5RaVIhx8QHwLYo=",
|
||||||
"path": "github.com/hashicorp/go-sockaddr",
|
"path": "github.com/hashicorp/go-sockaddr",
|
||||||
"revision": "3fe949359e7faa30c9dc5b4f921c7beddba1a27c",
|
"revision": "33afa667d8f9a6ca9d435a8f8c6e87af423c9356",
|
||||||
"revisionTime": "2016-12-02T06:02:17Z"
|
"revisionTime": "2016-12-02T07:02:37Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Y+c+ahUug8/vK+cWRLatV5aB4ps=",
|
"checksumSHA1": "Y+c+ahUug8/vK+cWRLatV5aB4ps=",
|
||||||
|
|
Loading…
Reference in New Issue