chore(deps): bump go-micro.dev/v4 from 4.10.2 to 4.11.0
Bumps [go-micro.dev/v4](https://github.com/go-micro/go-micro) from 4.10.2 to 4.11.0. - [Release notes](https://github.com/go-micro/go-micro/releases) - [Commits](https://github.com/go-micro/go-micro/compare/v4.10.2...v4.11.0) --- updated-dependencies: - dependency-name: go-micro.dev/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
cb89e98f28
commit
50e24b0318
+21
-5
@@ -35,8 +35,8 @@ func IsLocal(addr string) bool {
|
||||
}
|
||||
|
||||
// Extract returns a valid IP address. If the address provided is a valid
|
||||
// address, it will be returned directly. Otherwise the available interfaces
|
||||
// be itterated over to find an IP address, prefferably private.
|
||||
// address, it will be returned directly. Otherwise, the available interfaces
|
||||
// will be iterated over to find an IP address, preferably private.
|
||||
func Extract(addr string) (string, error) {
|
||||
// if addr is already specified then it's directly returned
|
||||
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
|
||||
@@ -115,10 +115,12 @@ func IPs() []string {
|
||||
return ipAddrs
|
||||
}
|
||||
|
||||
// findIP will return the first private IP available in the list,
|
||||
// if no private IP is available it will return a public IP if present.
|
||||
// findIP will return the first private IP available in the list.
|
||||
// If no private IP is available it will return the first public IP, if present.
|
||||
// If no public IP is available, it will return the first loopback IP, if present.
|
||||
func findIP(addresses []net.Addr) (net.IP, error) {
|
||||
var publicIP net.IP
|
||||
var localIP net.IP
|
||||
|
||||
for _, rawAddr := range addresses {
|
||||
var ip net.IP
|
||||
@@ -131,8 +133,17 @@ func findIP(addresses []net.Addr) (net.IP, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if ip.IsLoopback() {
|
||||
if localIP == nil {
|
||||
localIP = ip
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if !ip.IsPrivate() {
|
||||
publicIP = ip
|
||||
if publicIP == nil {
|
||||
publicIP = ip
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -145,5 +156,10 @@ func findIP(addresses []net.Addr) (net.IP, error) {
|
||||
return publicIP, nil
|
||||
}
|
||||
|
||||
// Return local IP
|
||||
if len(localIP) > 0 {
|
||||
return localIP, nil
|
||||
}
|
||||
|
||||
return nil, ErrIPNotFound
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user