mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-17 21:07:54 +02:00
Update host.go (#2013)
This commit is contained in:
parent
1dfb77bfe1
commit
2ee49311c1
@ -14,9 +14,6 @@ func ExtractHostPort(addr string) (host string, port uint64, err error) {
|
||||
return
|
||||
}
|
||||
port, err = strconv.ParseUint(ports, 10, 16) //nolint:gomnd
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -40,11 +37,11 @@ func Extract(hostPort string, lis net.Listener) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
if lis != nil {
|
||||
if p, ok := Port(lis); ok {
|
||||
port = strconv.Itoa(p)
|
||||
} else {
|
||||
p, ok := Port(lis)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("failed to extract port: %v", lis.Addr())
|
||||
}
|
||||
port = strconv.Itoa(p)
|
||||
}
|
||||
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
|
||||
return net.JoinHostPort(addr, port), nil
|
||||
@ -61,7 +58,8 @@ func Extract(hostPort string, lis net.Listener) (string, error) {
|
||||
}
|
||||
if iface.Index < lowest || result == nil {
|
||||
lowest = iface.Index
|
||||
} else if result != nil {
|
||||
}
|
||||
if result != nil {
|
||||
continue
|
||||
}
|
||||
addrs, err := iface.Addrs()
|
||||
|
Loading…
x
Reference in New Issue
Block a user