From f0f51f7f77c56eb64da188dfba0af2ff6588a920 Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Fri, 30 Mar 2018 09:56:55 -0700 Subject: [PATCH] check ranges bi-directionally --- cidr.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cidr.go b/cidr.go index 3c3c045..7f78ba4 100644 --- a/cidr.go +++ b/cidr.go @@ -67,7 +67,10 @@ func NoOverlap(subnets []*net.IPNet) error { firstLastIP[i] = []net.IP{first, last} } for i, s := range subnets { - for j := i + 1; j < len(subnets); j++ { + for j := range subnets { + if i == j { + continue + } first := firstLastIP[j][0] last := firstLastIP[j][1] if s.Contains(first) || s.Contains(last) {