From 22e40588938ae8b113fc76394ca10bfdb2af9dd0 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Thu, 12 Jul 2018 07:30:17 -0400 Subject: [PATCH] Use type switch instead of .Network for more reliably detecting UnixAddrs --- agent/config/runtime.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/agent/config/runtime.go b/agent/config/runtime.go index 0ee46aa61f..696153ef60 100644 --- a/agent/config/runtime.go +++ b/agent/config/runtime.go @@ -1202,13 +1202,17 @@ func (c *RuntimeConfig) apiAddresses(maxPerType int) (unixAddrs, httpAddrs, http unix_count := 0 http_count := 0 for _, addr := range c.HTTPAddrs { - net := addr.Network() - if net == "tcp" && http_count < maxPerType { - httpAddrs = append(httpAddrs, addr.String()) - http_count += 1 - } else if net != "tcp" && unix_count < maxPerType { - unixAddrs = append(unixAddrs, addr.String()) - unix_count += 1 + switch addr.(type) { + case *net.UnixAddr: + if unix_count < maxPerType { + unixAddrs = append(unixAddrs, addr.String()) + unix_count += 1 + } + default: + if http_count < maxPerType { + httpAddrs = append(httpAddrs, addr.String()) + http_count += 1 + } } } }