Model: Cap networkPrefixLengths to valid values
This commit is contained in:
parent
93be31e4e6
commit
7498e9556b
|
@ -28,7 +28,13 @@ extension IPAddressRange {
|
||||||
}
|
}
|
||||||
let networkPrefixLengthSubstring = string[indexOfNetworkPrefixLength ..< string.endIndex]
|
let networkPrefixLengthSubstring = string[indexOfNetworkPrefixLength ..< string.endIndex]
|
||||||
if let npl = UInt8(networkPrefixLengthSubstring) {
|
if let npl = UInt8(networkPrefixLengthSubstring) {
|
||||||
networkPrefixLength = npl
|
if (address is IPv4Address) {
|
||||||
|
networkPrefixLength = min(npl, 32)
|
||||||
|
} else if (address is IPv6Address) {
|
||||||
|
networkPrefixLength = min(npl, 128)
|
||||||
|
} else {
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue