1
0
mirror of https://github.com/smcquay/cidr/ synced 2024-12-04 05:39:36 -08:00

check ranges bi-directionally

This commit is contained in:
Stephen McQuay 2018-03-30 09:56:55 -07:00
parent 08019f5593
commit f0f51f7f77
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5

View File

@ -67,7 +67,10 @@ func NoOverlap(subnets []*net.IPNet) error {
firstLastIP[i] = []net.IP{first, last} firstLastIP[i] = []net.IP{first, last}
} }
for i, s := range subnets { 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] first := firstLastIP[j][0]
last := firstLastIP[j][1] last := firstLastIP[j][1]
if s.Contains(first) || s.Contains(last) { if s.Contains(first) || s.Contains(last) {