mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
bump hashicorp/go-sockaddr v1.0.2
full diff: 6d291a969b
...v1.0.2
Relevant changes:
- hashicorp/go-sockaddr#25 Add android os
- hashicorp/go-sockaddr#28 Add go.mod
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
720b66ee1f
commit
492945c2d5
5 changed files with 80 additions and 13 deletions
|
@ -47,7 +47,7 @@ github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ec
|
|||
github.com/hashicorp/memberlist 3d8438da9589e7b608a83ffac1ef8211486bcb7c
|
||||
github.com/sean-/seed e2103e2c35297fb7e17febb81e49b312087a2372
|
||||
github.com/hashicorp/errwrap 8a6fb523712970c966eefc6b39ed2c5e74880354 # v1.0.0
|
||||
github.com/hashicorp/go-sockaddr 6d291a969b86c4b633730bfc6b8b9d64c3aafed9
|
||||
github.com/hashicorp/go-sockaddr c7188e74f6acae5a989bdc959aa779f8b9f42faf # v1.0.2
|
||||
github.com/hashicorp/go-multierror 886a7fbe3eb1c874d46f623bfa70af45f425b3d1 # v1.0.0
|
||||
github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870
|
||||
github.com/docker/libkv 458977154600b9f23984d9f4b82e79570b5ae12b
|
||||
|
|
8
vendor/github.com/hashicorp/go-sockaddr/go.mod
generated
vendored
Normal file
8
vendor/github.com/hashicorp/go-sockaddr/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
module github.com/hashicorp/go-sockaddr
|
||||
|
||||
require (
|
||||
github.com/hashicorp/errwrap v1.0.0
|
||||
github.com/mitchellh/cli v1.0.0
|
||||
github.com/mitchellh/go-wordwrap v1.0.0
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible
|
||||
)
|
47
vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
generated
vendored
47
vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
generated
vendored
|
@ -1197,18 +1197,12 @@ func parseDefaultIfNameFromRoute(routeOut string) (string, error) {
|
|||
// parseDefaultIfNameFromIPCmd parses the default interface from ip(8) for
|
||||
// Linux.
|
||||
func parseDefaultIfNameFromIPCmd(routeOut string) (string, error) {
|
||||
lines := strings.Split(routeOut, "\n")
|
||||
re := whitespaceRE.Copy()
|
||||
for _, line := range lines {
|
||||
kvs := re.Split(line, -1)
|
||||
if len(kvs) < 5 {
|
||||
continue
|
||||
}
|
||||
|
||||
if kvs[0] == "default" &&
|
||||
kvs[1] == "via" &&
|
||||
kvs[3] == "dev" {
|
||||
ifName := strings.TrimSpace(kvs[4])
|
||||
parsedLines := parseIfNameFromIPCmd(routeOut)
|
||||
for _, parsedLine := range parsedLines {
|
||||
if parsedLine[0] == "default" &&
|
||||
parsedLine[1] == "via" &&
|
||||
parsedLine[3] == "dev" {
|
||||
ifName := strings.TrimSpace(parsedLine[4])
|
||||
return ifName, nil
|
||||
}
|
||||
}
|
||||
|
@ -1216,6 +1210,35 @@ func parseDefaultIfNameFromIPCmd(routeOut string) (string, error) {
|
|||
return "", errors.New("No default interface found")
|
||||
}
|
||||
|
||||
// parseDefaultIfNameFromIPCmdAndroid parses the default interface from ip(8) for
|
||||
// Android.
|
||||
func parseDefaultIfNameFromIPCmdAndroid(routeOut string) (string, error) {
|
||||
parsedLines := parseIfNameFromIPCmd(routeOut)
|
||||
if (len(parsedLines) > 0) {
|
||||
ifName := strings.TrimSpace(parsedLines[0][4])
|
||||
return ifName, nil
|
||||
}
|
||||
|
||||
return "", errors.New("No default interface found")
|
||||
}
|
||||
|
||||
|
||||
// parseIfNameFromIPCmd parses interfaces from ip(8) for
|
||||
// Linux.
|
||||
func parseIfNameFromIPCmd(routeOut string) [][]string {
|
||||
lines := strings.Split(routeOut, "\n")
|
||||
re := whitespaceRE.Copy()
|
||||
parsedLines := make([][]string, 0, len(lines))
|
||||
for _, line := range lines {
|
||||
kvs := re.Split(line, -1)
|
||||
if len(kvs) < 5 {
|
||||
continue
|
||||
}
|
||||
parsedLines = append(parsedLines, kvs)
|
||||
}
|
||||
return parsedLines
|
||||
}
|
||||
|
||||
// parseDefaultIfNameWindows parses the default interface from `netstat -rn` and
|
||||
// `ipconfig` on Windows.
|
||||
func parseDefaultIfNameWindows(routeOut, ipconfigOut string) (string, error) {
|
||||
|
|
34
vendor/github.com/hashicorp/go-sockaddr/route_info_android.go
generated
vendored
Normal file
34
vendor/github.com/hashicorp/go-sockaddr/route_info_android.go
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
package sockaddr
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type routeInfo struct {
|
||||
cmds map[string][]string
|
||||
}
|
||||
|
||||
// NewRouteInfo returns a Android-specific implementation of the RouteInfo
|
||||
// interface.
|
||||
func NewRouteInfo() (routeInfo, error) {
|
||||
return routeInfo{
|
||||
cmds: map[string][]string{"ip": {"/system/bin/ip", "route", "get", "8.8.8.8"}},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetDefaultInterfaceName returns the interface name attached to the default
|
||||
// route on the default interface.
|
||||
func (ri routeInfo) GetDefaultInterfaceName() (string, error) {
|
||||
out, err := exec.Command(ri.cmds["ip"][0], ri.cmds["ip"][1:]...).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
var ifName string
|
||||
if ifName, err = parseDefaultIfNameFromIPCmdAndroid(string(out)); err != nil {
|
||||
return "", errors.New("No default interface found")
|
||||
}
|
||||
return ifName, nil
|
||||
}
|
2
vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go
generated
vendored
2
vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go
generated
vendored
|
@ -1,3 +1,5 @@
|
|||
// +build !android
|
||||
|
||||
package sockaddr
|
||||
|
||||
import (
|
||||
|
|
Loading…
Add table
Reference in a new issue