Fix invalid IPv6 notation
This commit is contained in:
parent
524ab50df7
commit
134e27feb6
@ -32,7 +32,7 @@ pub fn is_ipv4_mask_valid(mask: u8) -> bool {
|
||||
}
|
||||
|
||||
pub fn is_ipv6_mask_valid(mask: u8) -> bool {
|
||||
mask <= 64
|
||||
mask <= 128
|
||||
}
|
||||
|
||||
pub fn is_mask_valid(ipv: usize, mask: u8) -> bool {
|
||||
@ -79,6 +79,7 @@ mod tests {
|
||||
assert!(is_ipv6_address_valid("fe80::"));
|
||||
assert!(is_ipv6_address_valid("fe80:dd::"));
|
||||
assert!(is_ipv6_address_valid("00:00:00:00:00::"));
|
||||
assert!(is_ipv6_address_valid("0:0:0:0:0:0:0:0"));
|
||||
|
||||
assert!(!is_ipv6_address_valid("tata"));
|
||||
assert!(!is_ipv6_address_valid("2.56.58.156"));
|
||||
@ -93,6 +94,8 @@ mod tests {
|
||||
assert!(is_mask_valid(6, 34));
|
||||
|
||||
assert!(!is_mask_valid(4, 34));
|
||||
assert!(!is_mask_valid(6, 69));
|
||||
assert!(is_mask_valid(6, 69));
|
||||
assert!(is_mask_valid(6, 128));
|
||||
assert!(!is_mask_valid(6, 129));
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +128,6 @@ function sanitizeMask(version: 4 | 6, mask?: string): number | undefined {
|
||||
if (version === 4) {
|
||||
return value < 0 || value > 32 ? 32 : value;
|
||||
} else {
|
||||
return value < 0 || value > 64 ? 64 : value;
|
||||
return value < 0 || value > 128 ? 128 : value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user