diff --git a/virtweb_backend/src/utils/net_utils.rs b/virtweb_backend/src/utils/net_utils.rs index d9bf679..e5cffe9 100644 --- a/virtweb_backend/src/utils/net_utils.rs +++ b/virtweb_backend/src/utils/net_utils.rs @@ -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)); } } diff --git a/virtweb_frontend/src/widgets/forms/IPInput.tsx b/virtweb_frontend/src/widgets/forms/IPInput.tsx index c497e7a..c7db678 100644 --- a/virtweb_frontend/src/widgets/forms/IPInput.tsx +++ b/virtweb_frontend/src/widgets/forms/IPInput.tsx @@ -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; } }