mirror of https://github.com/status-im/consul.git
Use type switch instead of .Network for more reliably detecting UnixAddrs
This commit is contained in:
parent
700a275ddf
commit
22e4058893
|
@ -1202,13 +1202,17 @@ func (c *RuntimeConfig) apiAddresses(maxPerType int) (unixAddrs, httpAddrs, http
|
||||||
unix_count := 0
|
unix_count := 0
|
||||||
http_count := 0
|
http_count := 0
|
||||||
for _, addr := range c.HTTPAddrs {
|
for _, addr := range c.HTTPAddrs {
|
||||||
net := addr.Network()
|
switch addr.(type) {
|
||||||
if net == "tcp" && http_count < maxPerType {
|
case *net.UnixAddr:
|
||||||
httpAddrs = append(httpAddrs, addr.String())
|
if unix_count < maxPerType {
|
||||||
http_count += 1
|
unixAddrs = append(unixAddrs, addr.String())
|
||||||
} else if net != "tcp" && unix_count < maxPerType {
|
unix_count += 1
|
||||||
unixAddrs = append(unixAddrs, addr.String())
|
}
|
||||||
unix_count += 1
|
default:
|
||||||
|
if http_count < maxPerType {
|
||||||
|
httpAddrs = append(httpAddrs, addr.String())
|
||||||
|
http_count += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue