diff --git a/core/ui/public/i18n/en/translation.json b/core/ui/public/i18n/en/translation.json index 42b70445f..d30399312 100644 --- a/core/ui/public/i18n/en/translation.json +++ b/core/ui/public/i18n/en/translation.json @@ -821,8 +821,9 @@ "instance_pattern": "Allowed characters: A-Z, a-z, 0-9, _ and -", "ip_allowlist": "Allow access from (optional)", "ip_allowlist_placeholder": "Eg. 192.168.7.0/24", - "ip_allowlist_helper": "Enter one IPv4 or CIDR address per line. Leave empty to allow access from any IP address", + "ip_allowlist_helper": "Enter one IPv4/IPv6 or CIDR address per line. Leave empty to allow access from any IP address", "invalid_ipv4": "Invalid IPv4 address: {ip}", + "invalid_ipv6": "Invalid IPv6 address: {ip}", "automatic": "Automatic", "restricted": "Access restricted", "attributes": "Attributes", diff --git a/core/ui/src/components/settings/CreateOrEditHttpRouteModal.vue b/core/ui/src/components/settings/CreateOrEditHttpRouteModal.vue index 08630ffeb..7fe144fb4 100644 --- a/core/ui/src/components/settings/CreateOrEditHttpRouteModal.vue +++ b/core/ui/src/components/settings/CreateOrEditHttpRouteModal.vue @@ -502,11 +502,16 @@ export default { // IPv4 and IPv4 CIDR pattern const ipv4Pattern = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[1-2][0-9]|3[0-2]))?$/; + // IPv6 and IPv6 CIDR pattern + const ipv6Pattern = + /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/; for (const ip of ipList) { - if (!ipv4Pattern.test(ip)) { + if (!ipv4Pattern.test(ip) && !ipv6Pattern.test(ip)) { + // Determine if it looks like an IPv6 address + const isIPv6Like = ip.includes(":") || ip.includes("::"); this.error.ip_allowlist = this.$t( - "settings_http_routes.invalid_ipv4", + isIPv6Like ? "settings_http_routes.invalid_ipv6" : "settings_http_routes.invalid_ipv4", { ip: ip } ); if (isValidationOk) {