Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading