From 20ce708db97dfc71fa7bb801fa5c28357773c8fc Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 4 Jun 2018 16:41:24 +0000 Subject: [PATCH] Don't bother deduplicating IPs; they end up in a set --- probe/docker/container.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/probe/docker/container.go b/probe/docker/container.go index 7e7d4edc9..b11a65591 100644 --- a/probe/docker/container.go +++ b/probe/docker/container.go @@ -268,15 +268,6 @@ func isIPv4(addr string) bool { return ip != nil && ip.To4() != nil } -func contains(strs []string, str string) bool { - for _, s := range strs { - if s == str { - return true - } - } - return false -} - func (c *container) NetworkInfo(localAddrs []net.IP) report.Sets { c.RLock() defer c.RUnlock() @@ -292,10 +283,9 @@ func (c *container) NetworkInfo(localAddrs []net.IP) report.Sets { log.Debugf("container %s: failed to get addresses: %s", c.container.ID, err) } for _, cidr := range cidrs { - ip := cidr.IP.String() - if !contains(ips, ip) { - ips = append(ips, ip) - } + // This address can duplicate an address fetched from Docker earlier, + // but we eventually turn the lists into sets which will remove duplicates. + ips = append(ips, cidr.IP.String()) } // For now, for the proof-of-concept, we just add networks as a set of