From eef0b99774534636cfd0a38d273a92101b04e1d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:30:59 +0000 Subject: [PATCH] Bump github.com/hashicorp/go-sockaddr from 1.0.2 to 1.0.5 Bumps [github.com/hashicorp/go-sockaddr](https://github.com/hashicorp/go-sockaddr) from 1.0.2 to 1.0.5. - [Commits](https://github.com/hashicorp/go-sockaddr/compare/v1.0.2...v1.0.5) --- updated-dependencies: - dependency-name: github.com/hashicorp/go-sockaddr dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 7 ++--- .../github.com/hashicorp/go-sockaddr/LICENSE | 2 ++ .../hashicorp/go-sockaddr/ifaddrs.go | 21 ++++++++++--- .../go-sockaddr/route_info_test_windows.go | 25 ++++++++++++++++ .../go-sockaddr/route_info_windows.go | 30 ++++++++++++++++++- .../hashicorp/go-sockaddr/unixsock.go | 13 ++++++++ vendor/modules.txt | 4 +-- 8 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-sockaddr/route_info_test_windows.go diff --git a/go.mod b/go.mod index 2aa7693f44..5195e87389 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/hashicorp/consul/api v1.25.1 github.com/hashicorp/go-cleanhttp v0.5.2 - github.com/hashicorp/go-sockaddr v1.0.2 + github.com/hashicorp/go-sockaddr v1.0.5 github.com/hashicorp/memberlist v0.5.0 github.com/json-iterator/go v1.1.12 github.com/klauspost/compress v1.17.2 diff --git a/go.sum b/go.sum index 97be76a152..3826720f8b 100644 --- a/go.sum +++ b/go.sum @@ -925,8 +925,8 @@ github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5 github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/go-sockaddr v1.0.5 h1:dvk7TIXCZpmfOlM+9mlcrWmWjw/wlKT+VDq2wMvfPJU= +github.com/hashicorp/go-sockaddr v1.0.5/go.mod h1:uoUUmtwU7n9Dv3O4SNLeFvg0SxQ3lyjsj6+CCykpaxI= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1071,12 +1071,10 @@ github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurw github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -1211,7 +1209,6 @@ github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.6.0/go.mod h1:U8+INwJo3nBv1m6A/8OBXAq7Jnpspk5AxSgDyEQcea8= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.20 h1:a9hSJdJcd16e0HoMsnFvaHvxB3pxSD+SC7+CISp7xY0= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.20/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= diff --git a/vendor/github.com/hashicorp/go-sockaddr/LICENSE b/vendor/github.com/hashicorp/go-sockaddr/LICENSE index a612ad9813..be467e386b 100644 --- a/vendor/github.com/hashicorp/go-sockaddr/LICENSE +++ b/vendor/github.com/hashicorp/go-sockaddr/LICENSE @@ -1,3 +1,5 @@ +Copyright (c) 2016 HashiCorp, Inc. + Mozilla Public License Version 2.0 ================================== diff --git a/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go b/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go index 80f61bef68..d2713afbf7 100644 --- a/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go +++ b/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go @@ -16,8 +16,10 @@ var ( // Centralize all regexps and regexp.Copy() where necessary. signRE *regexp.Regexp = regexp.MustCompile(`^[\s]*[+-]`) whitespaceRE *regexp.Regexp = regexp.MustCompile(`[\s]+`) - ifNameRE *regexp.Regexp = regexp.MustCompile(`^(?:Ethernet|Wireless LAN) adapter ([^:]+):`) - ipAddrRE *regexp.Regexp = regexp.MustCompile(`^ IPv[46] Address\. \. \. \. \. \. \. \. \. \. \. : ([^\s]+)`) + // These regular expressions enable the deprecated parseDefaultIfNameWindows + // and should be removed when those functions are. + ifNameRE *regexp.Regexp = regexp.MustCompile(`^(?:Ethernet|Wireless LAN) adapter ([^:]+):`) + ipAddrRE *regexp.Regexp = regexp.MustCompile(`^ IPv[46] Address\. \. \. \. \. \. \. \. \. \. \. : ([^\s]+)`) ) // IfAddrs is a slice of IfAddr @@ -1214,7 +1216,7 @@ func parseDefaultIfNameFromIPCmd(routeOut string) (string, error) { // Android. func parseDefaultIfNameFromIPCmdAndroid(routeOut string) (string, error) { parsedLines := parseIfNameFromIPCmd(routeOut) - if (len(parsedLines) > 0) { + if len(parsedLines) > 0 { ifName := strings.TrimSpace(parsedLines[0][4]) return ifName, nil } @@ -1222,7 +1224,6 @@ func parseDefaultIfNameFromIPCmdAndroid(routeOut string) (string, error) { return "", errors.New("No default interface found") } - // parseIfNameFromIPCmd parses interfaces from ip(8) for // Linux. func parseIfNameFromIPCmd(routeOut string) [][]string { @@ -1241,6 +1242,10 @@ func parseIfNameFromIPCmd(routeOut string) [][]string { // parseDefaultIfNameWindows parses the default interface from `netstat -rn` and // `ipconfig` on Windows. +// +// This has been deprecated in favor of a Powershell-based solution because of +// issues with localized Windows versions, but is currently retained for backward +// compatibility func parseDefaultIfNameWindows(routeOut, ipconfigOut string) (string, error) { defaultIPAddr, err := parseDefaultIPAddrWindowsRoute(routeOut) if err != nil { @@ -1262,6 +1267,10 @@ func parseDefaultIfNameWindows(routeOut, ipconfigOut string) (string, error) { // IPv6 connected host, submit an issue on github.com/hashicorp/go-sockaddr with // the output from `netstat -rn`, `ipconfig`, and version of Windows to see IPv6 // support added. +// +// This has been deprecated in favor of a Powershell-based solution because of +// issues with localized Windows versions, but is currently retained for backward +// compatibility. func parseDefaultIPAddrWindowsRoute(routeOut string) (string, error) { lines := strings.Split(routeOut, "\n") re := whitespaceRE.Copy() @@ -1282,6 +1291,10 @@ func parseDefaultIPAddrWindowsRoute(routeOut string) (string, error) { // parseDefaultIfNameWindowsIPConfig parses the output of `ipconfig` to find the // interface name forwarding traffic to the default gateway. +// +// This has been deprecated in favor of a Powershell-based solution because of +// issues with localized Windows versions, but is currently retained for backward +// compatibility func parseDefaultIfNameWindowsIPConfig(defaultIPAddr, routeOut string) (string, error) { lines := strings.Split(routeOut, "\n") ifNameRe := ifNameRE.Copy() diff --git a/vendor/github.com/hashicorp/go-sockaddr/route_info_test_windows.go b/vendor/github.com/hashicorp/go-sockaddr/route_info_test_windows.go new file mode 100644 index 0000000000..a6eacdb2cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-sockaddr/route_info_test_windows.go @@ -0,0 +1,25 @@ +package sockaddr + +import "testing" + +func Test_parseWindowsDefaultIfName_new_vs_old(t *testing.T) { + if !hasPowershell() { + t.Skip("this test requires powershell.") + return + } + ri, err := NewRouteInfo() + if err != nil { + t.Fatalf("bad: %v", err) + } + psVer, err1 := ri.GetDefaultInterfaceName() + legacyVer, err2 := ri.GetDefaultInterfaceNameLegacy() + if err1 != nil { + t.Errorf("err != nil for GetDefaultInterfaceName - %v", err1) + } + if err2 != nil { + t.Errorf("err != nil for GetDefaultInterfaceNameLegacy - %v", err2) + } + if psVer != legacyVer { + t.Errorf("got %s; want %s", psVer, legacyVer) + } +} diff --git a/vendor/github.com/hashicorp/go-sockaddr/route_info_windows.go b/vendor/github.com/hashicorp/go-sockaddr/route_info_windows.go index 3da972883e..087fad95e0 100644 --- a/vendor/github.com/hashicorp/go-sockaddr/route_info_windows.go +++ b/vendor/github.com/hashicorp/go-sockaddr/route_info_windows.go @@ -1,8 +1,14 @@ package sockaddr -import "os/exec" +import ( + "os/exec" + "strings" +) var cmds map[string][]string = map[string][]string{ + "defaultInterface": {"powershell", "Get-NetRoute -DestinationPrefix '0.0.0.0/0' | select -ExpandProperty InterfaceAlias"}, + // These commands enable GetDefaultInterfaceNameLegacy and should be removed + // when it is. "netstat": {"netstat", "-rn"}, "ipconfig": {"ipconfig"}, } @@ -22,6 +28,23 @@ func NewRouteInfo() (routeInfo, error) { // GetDefaultInterfaceName returns the interface name attached to the default // route on the default interface. func (ri routeInfo) GetDefaultInterfaceName() (string, error) { + if !hasPowershell() { + // No powershell, fallback to legacy method + return ri.GetDefaultInterfaceNameLegacy() + } + + ifNameOut, err := exec.Command(cmds["defaultInterface"][0], cmds["defaultInterface"][1:]...).Output() + if err != nil { + return "", err + } + + ifName := strings.TrimSpace(string(ifNameOut[:])) + return ifName, nil +} + +// GetDefaultInterfaceNameLegacy provides legacy behavior for GetDefaultInterfaceName +// on Windows machines without powershell. +func (ri routeInfo) GetDefaultInterfaceNameLegacy() (string, error) { ifNameOut, err := exec.Command(cmds["netstat"][0], cmds["netstat"][1:]...).Output() if err != nil { return "", err @@ -39,3 +62,8 @@ func (ri routeInfo) GetDefaultInterfaceName() (string, error) { return ifName, nil } + +func hasPowershell() bool { + _, err := exec.LookPath("powershell") + return (err != nil) +} diff --git a/vendor/github.com/hashicorp/go-sockaddr/unixsock.go b/vendor/github.com/hashicorp/go-sockaddr/unixsock.go index f3be3f67e7..17aed98adf 100644 --- a/vendor/github.com/hashicorp/go-sockaddr/unixsock.go +++ b/vendor/github.com/hashicorp/go-sockaddr/unixsock.go @@ -27,6 +27,16 @@ func NewUnixSock(s string) (ret UnixSock, err error) { return ret, nil } +// Contains returns true if sa and us have the same path +func (us UnixSock) Contains(sa SockAddr) bool { + usb, ok := sa.(UnixSock) + if !ok { + return false + } + + return usb.path == us.path +} + // CmpAddress follows the Cmp() standard protocol and returns: // // - -1 If the receiver should sort first because its name lexically sorts before arg @@ -41,6 +51,9 @@ func (us UnixSock) CmpAddress(sa SockAddr) int { return strings.Compare(us.Path(), usb.Path()) } +// CmpRFC doesn't make sense for a Unix socket, so just return defer decision +func (us UnixSock) CmpRFC(rfcNum uint, sa SockAddr) int { return sortDeferDecision } + // DialPacketArgs returns the arguments required to be passed to net.DialUnix() // with the `unixgram` network type. func (us UnixSock) DialPacketArgs() (network, dialArgs string) { diff --git a/vendor/modules.txt b/vendor/modules.txt index eefb2284a6..5d7407559e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -532,8 +532,8 @@ github.com/hashicorp/go-multierror # github.com/hashicorp/go-rootcerts v1.0.2 ## explicit; go 1.12 github.com/hashicorp/go-rootcerts -# github.com/hashicorp/go-sockaddr v1.0.2 -## explicit +# github.com/hashicorp/go-sockaddr v1.0.5 +## explicit; go 1.19 github.com/hashicorp/go-sockaddr # github.com/hashicorp/golang-lru v0.6.0 ## explicit; go 1.12