Update host.go (#2013)

status-code-override
songzhibin97 3 years ago committed by chenzhihui
parent 769a40957c
commit 291f0f3ad0
  1. 12
      internal/host/host.go

@ -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…
Cancel
Save