Simplify NetworkOverlaps function
- Doing a lot of unnecessary things. Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
f7d4913ab9
commit
26ac09e004
|
@ -59,17 +59,7 @@ func CheckRouteOverlaps(toCheck *net.IPNet) error {
|
||||||
|
|
||||||
// NetworkOverlaps detects overlap between one IPNet and another
|
// NetworkOverlaps detects overlap between one IPNet and another
|
||||||
func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool {
|
func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool {
|
||||||
// Check if both netX and netY are ipv4 or ipv6
|
return netX.Contains(netY.IP) || netY.Contains(netX.IP)
|
||||||
if (netX.IP.To4() != nil && netY.IP.To4() != nil) ||
|
|
||||||
(netX.IP.To4() == nil && netY.IP.To4() == nil) {
|
|
||||||
if firstIP, _ := NetworkRange(netX); netY.Contains(firstIP) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if firstIP, _ := NetworkRange(netY); netX.Contains(firstIP) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkRange calculates the first and last IP addresses in an IPNet
|
// NetworkRange calculates the first and last IP addresses in an IPNet
|
||||||
|
|
Loading…
Reference in New Issue