mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #442 from aboch/csb
Simplify NetworkOverlaps function
This commit is contained in:
commit
7f15aee70e
1 changed files with 1 additions and 11 deletions
|
@ -59,17 +59,7 @@ func CheckRouteOverlaps(toCheck *net.IPNet) error {
|
|||
|
||||
// NetworkOverlaps detects overlap between one IPNet and another
|
||||
func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool {
|
||||
// Check if both netX and netY are ipv4 or ipv6
|
||||
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
|
||||
return netX.Contains(netY.IP) || netY.Contains(netX.IP)
|
||||
}
|
||||
|
||||
// NetworkRange calculates the first and last IP addresses in an IPNet
|
||||
|
|
Loading…
Reference in a new issue