mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
Small vendor update for go-sockaddr: now able to filter by CIDR.
This commit is contained in:
parent
4d82f1018b
commit
24192f4d48
31
vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
generated
vendored
31
vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
generated
vendored
@ -486,7 +486,10 @@ func IfByType(inputTypes string, ifAddrs IfAddrs) (matched, remainder IfAddrs, e
|
|||||||
|
|
||||||
ifTypes := strings.Split(strings.ToLower(inputTypes), "|")
|
ifTypes := strings.Split(strings.ToLower(inputTypes), "|")
|
||||||
for _, ifType := range ifTypes {
|
for _, ifType := range ifTypes {
|
||||||
if ifType != "ip" && ifType != "ipv4" && ifType != "ipv6" && ifType != "unix" {
|
switch ifType {
|
||||||
|
case "ip", "ipv4", "ipv6", "unix":
|
||||||
|
// Valid types
|
||||||
|
default:
|
||||||
return nil, nil, fmt.Errorf("unsupported type %q %q", ifType, inputTypes)
|
return nil, nil, fmt.Errorf("unsupported type %q %q", ifType, inputTypes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -622,6 +625,28 @@ func IfByFlag(inputFlags string, ifAddrs IfAddrs) (matched, remainder IfAddrs, e
|
|||||||
return matchedAddrs, excludedAddrs, nil
|
return matchedAddrs, excludedAddrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IfByNetwork returns an IfAddrs that are equal to or included within the
|
||||||
|
// network passed in by selector.
|
||||||
|
func IfByNetwork(selectorParam string, inputIfAddrs IfAddrs) (IfAddrs, IfAddrs, error) {
|
||||||
|
var includedIfs, excludedIfs IfAddrs
|
||||||
|
for _, netStr := range strings.Split(selectorParam, "|") {
|
||||||
|
netAddr, err := NewIPAddr(netStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("unable to create an IP address from %+q: %v", netStr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ifAddr := range inputIfAddrs {
|
||||||
|
if netAddr.Contains(ifAddr.SockAddr) {
|
||||||
|
includedIfs = append(includedIfs, ifAddr)
|
||||||
|
} else {
|
||||||
|
excludedIfs = append(excludedIfs, ifAddr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return includedIfs, excludedIfs, nil
|
||||||
|
}
|
||||||
|
|
||||||
// IncludeIfs returns an IfAddrs based on the passed in selector.
|
// IncludeIfs returns an IfAddrs based on the passed in selector.
|
||||||
func IncludeIfs(selectorName, selectorParam string, inputIfAddrs IfAddrs) (IfAddrs, error) {
|
func IncludeIfs(selectorName, selectorParam string, inputIfAddrs IfAddrs) (IfAddrs, error) {
|
||||||
var includedIfs IfAddrs
|
var includedIfs IfAddrs
|
||||||
@ -634,6 +659,8 @@ func IncludeIfs(selectorName, selectorParam string, inputIfAddrs IfAddrs) (IfAdd
|
|||||||
includedIfs, _, err = IfByFlag(selectorParam, inputIfAddrs)
|
includedIfs, _, err = IfByFlag(selectorParam, inputIfAddrs)
|
||||||
case "name":
|
case "name":
|
||||||
includedIfs, _, err = IfByName(selectorParam, inputIfAddrs)
|
includedIfs, _, err = IfByName(selectorParam, inputIfAddrs)
|
||||||
|
case "network":
|
||||||
|
includedIfs, _, err = IfByNetwork(selectorParam, inputIfAddrs)
|
||||||
case "port":
|
case "port":
|
||||||
includedIfs, _, err = IfByPort(selectorParam, inputIfAddrs)
|
includedIfs, _, err = IfByPort(selectorParam, inputIfAddrs)
|
||||||
case "rfc", "rfcs":
|
case "rfc", "rfcs":
|
||||||
@ -665,6 +692,8 @@ func ExcludeIfs(selectorName, selectorParam string, inputIfAddrs IfAddrs) (IfAdd
|
|||||||
_, excludedIfs, err = IfByFlag(selectorParam, inputIfAddrs)
|
_, excludedIfs, err = IfByFlag(selectorParam, inputIfAddrs)
|
||||||
case "name":
|
case "name":
|
||||||
_, excludedIfs, err = IfByName(selectorParam, inputIfAddrs)
|
_, excludedIfs, err = IfByName(selectorParam, inputIfAddrs)
|
||||||
|
case "network":
|
||||||
|
_, excludedIfs, err = IfByNetwork(selectorParam, inputIfAddrs)
|
||||||
case "port":
|
case "port":
|
||||||
_, excludedIfs, err = IfByPort(selectorParam, inputIfAddrs)
|
_, excludedIfs, err = IfByPort(selectorParam, inputIfAddrs)
|
||||||
case "rfc", "rfcs":
|
case "rfc", "rfcs":
|
||||||
|
12
vendor/vendor.json
vendored
12
vendor/vendor.json
vendored
@ -420,16 +420,16 @@
|
|||||||
"revisionTime": "2016-09-30T03:51:02Z"
|
"revisionTime": "2016-09-30T03:51:02Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "LmCRW89WaBzau5RaVIhx8QHwLYo=",
|
"checksumSHA1": "gnhc8egaCa7Ue516rnQkfutdBO8=",
|
||||||
"path": "github.com/hashicorp/go-sockaddr",
|
"path": "github.com/hashicorp/go-sockaddr",
|
||||||
"revision": "33afa667d8f9a6ca9d435a8f8c6e87af423c9356",
|
"revision": "af174a6fe6c9f9a049a638e1dae7bc4442c4d426",
|
||||||
"revisionTime": "2016-12-02T07:02:37Z"
|
"revisionTime": "2016-12-02T14:18:37Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Y+c+ahUug8/vK+cWRLatV5aB4ps=",
|
"checksumSHA1": "lPzwetgfMBtpHqdTPolgejMctVQ=",
|
||||||
"path": "github.com/hashicorp/go-sockaddr/template",
|
"path": "github.com/hashicorp/go-sockaddr/template",
|
||||||
"revision": "a99c57b5a5f48c51607e63089075fe7434fe219a",
|
"revision": "af174a6fe6c9f9a049a638e1dae7bc4442c4d426",
|
||||||
"revisionTime": "2016-12-02T03:16:41Z"
|
"revisionTime": "2016-12-02T14:18:37Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "xZ7Ban1x//6uUIU1xtrTbCYNHBc=",
|
"checksumSHA1": "xZ7Ban1x//6uUIU1xtrTbCYNHBc=",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user