Don't bother deduplicating IPs; they end up in a set

This commit is contained in:
Bryan Boreham
2018-06-04 16:41:24 +00:00
parent c6c51f36f7
commit 20ce708db9

View File

@@ -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