diff --git a/PVE/OpenVZ.pm b/PVE/OpenVZ.pm index a16d4fc21..2b9297940 100644 --- a/PVE/OpenVZ.pm +++ b/PVE/OpenVZ.pm @@ -6,7 +6,7 @@ use File::stat qw(); use POSIX qw (LONG_MAX); use IO::Dir; use IO::File; -use PVE::Tools qw(extract_param); +use PVE::Tools qw(extract_param $IPV6RE $IPV4RE); use PVE::ProcFSTools; use PVE::Cluster qw(cfs_register_file cfs_read_file); use PVE::SafeSyslog; @@ -1064,7 +1064,7 @@ sub update_ovz_config { } my $newhash = {}; foreach my $ip (PVE::Tools::split_list($param->{'ip_address'})) { - next if $ip !~ m|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d+)?$|; + next if $ip !~ m!^(?:$IPV6RE|$IPV4RE)(?:/\d+)?$!; $newhash->{$ip} = 1; if (!$iphash->{$ip}) { push @$changes, '--ipadd', $ip; diff --git a/debian/changelog.Debian b/debian/changelog.Debian index 6b21205bb..b5eff107e 100644 --- a/debian/changelog.Debian +++ b/debian/changelog.Debian @@ -3,6 +3,8 @@ pve-manager (3.1-23) unstable; urgency=low * subscription updates: set UserAgent header on proxy connect request * correctly set content type for GUI index page + + * allow to add ipv6 address to OpenVZ containers -- Proxmox Support Team Tue, 29 Oct 2013 10:20:02 +0100 diff --git a/www/manager/Utils.js b/www/manager/Utils.js index 001f0afc4..e366d3925 100644 --- a/www/manager/Utils.js +++ b/www/manager/Utils.js @@ -25,14 +25,42 @@ Ext.Ajax.on('beforerequest', function(conn, options) { } }); +var IPV4_OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])"; +var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")"; +var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})"; +var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")"; + + +var IP4_match = new RegExp("^(" + IPV4_REGEXP + ")$"); + +var IPV6_REGEXP = "(?:" + + "(?:(?:" + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" + + "(?:(?:" + "::" + "(?:" + IPV6_H16 + ":){5})" + IPV6_LS32 + ")|" + + "(?:(?:(?:" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){4})" + IPV6_LS32 + ")|" + + "(?:(?:(?:(?:" + IPV6_H16 + ":){0,1}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){3})" + IPV6_LS32 + ")|" + + "(?:(?:(?:(?:" + IPV6_H16 + ":){0,2}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){2})" + IPV6_LS32 + ")|" + + "(?:(?:(?:(?:" + IPV6_H16 + ":){0,3}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){1})" + IPV6_LS32 + ")|" + + "(?:(?:(?:(?:" + IPV6_H16 + ":){0,4}" + IPV6_H16 + ")?::" + ")" + IPV6_LS32 + ")|" + + "(?:(?:(?:(?:" + IPV6_H16 + ":){0,5}" + IPV6_H16 + ")?::" + ")" + IPV6_H16 + ")|" + + "(?:(?:(?:(?:" + IPV6_H16 + ":){0,7}" + IPV6_H16 + ")?::" + ")" + ")" + + ")"; + +var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + ")$"); + // custom Vtypes Ext.apply(Ext.form.field.VTypes, { IPAddress: function(v) { - return (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/).test(v); + return IP64_match.test(v); }, IPAddressText: gettext('Example') + ': 192.168.1.1', IPAddressMask: /[\d\.]/i, + IP64Address: function(v) { + return IP64_match.test(v); + }, + IP64AddressText: gettext('Example') + ': 192.168.1.1 2001:DB8::42', + IP64AddressMask: /[A-Fa-f0-9\.:]/, + MacAddress: function(v) { return (/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/).test(v); }, diff --git a/www/manager/openvz/Network.js b/www/manager/openvz/Network.js index 6d03d017c..a7a72b6f3 100644 --- a/www/manager/openvz/Network.js +++ b/www/manager/openvz/Network.js @@ -140,7 +140,7 @@ Ext.define('PVE.OpenVZ.IPAdd', { xtype: 'textfield', name: 'ipaddress', fieldLabel: gettext('IP address'), - vtype: 'IPAddress', + vtype: 'IP64Address', allowBlank: false } });