Commit 8ee71a18 authored by Dietmar Maurer's avatar Dietmar Maurer

allow to add ipv6 address to OpenVZ containers

parent 45c7d959
...@@ -6,7 +6,7 @@ use File::stat qw(); ...@@ -6,7 +6,7 @@ use File::stat qw();
use POSIX qw (LONG_MAX); use POSIX qw (LONG_MAX);
use IO::Dir; use IO::Dir;
use IO::File; use IO::File;
use PVE::Tools qw(extract_param); use PVE::Tools qw(extract_param $IPV6RE $IPV4RE);
use PVE::ProcFSTools; use PVE::ProcFSTools;
use PVE::Cluster qw(cfs_register_file cfs_read_file); use PVE::Cluster qw(cfs_register_file cfs_read_file);
use PVE::SafeSyslog; use PVE::SafeSyslog;
...@@ -1064,7 +1064,7 @@ sub update_ovz_config { ...@@ -1064,7 +1064,7 @@ sub update_ovz_config {
} }
my $newhash = {}; my $newhash = {};
foreach my $ip (PVE::Tools::split_list($param->{'ip_address'})) { 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; $newhash->{$ip} = 1;
if (!$iphash->{$ip}) { if (!$iphash->{$ip}) {
push @$changes, '--ipadd', $ip; push @$changes, '--ipadd', $ip;
......
...@@ -3,6 +3,8 @@ pve-manager (3.1-23) unstable; urgency=low ...@@ -3,6 +3,8 @@ pve-manager (3.1-23) unstable; urgency=low
* subscription updates: set UserAgent header on proxy connect request * subscription updates: set UserAgent header on proxy connect request
* correctly set content type for GUI index page * correctly set content type for GUI index page
* allow to add ipv6 address to OpenVZ containers
-- Proxmox Support Team <support@proxmox.com> Tue, 29 Oct 2013 10:20:02 +0100 -- Proxmox Support Team <support@proxmox.com> Tue, 29 Oct 2013 10:20:02 +0100
......
...@@ -25,14 +25,42 @@ Ext.Ajax.on('beforerequest', function(conn, options) { ...@@ -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 // custom Vtypes
Ext.apply(Ext.form.field.VTypes, { Ext.apply(Ext.form.field.VTypes, {
IPAddress: function(v) { 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', IPAddressText: gettext('Example') + ': 192.168.1.1',
IPAddressMask: /[\d\.]/i, 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) { MacAddress: function(v) {
return (/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/).test(v); return (/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/).test(v);
}, },
......
...@@ -140,7 +140,7 @@ Ext.define('PVE.OpenVZ.IPAdd', { ...@@ -140,7 +140,7 @@ Ext.define('PVE.OpenVZ.IPAdd', {
xtype: 'textfield', xtype: 'textfield',
name: 'ipaddress', name: 'ipaddress',
fieldLabel: gettext('IP address'), fieldLabel: gettext('IP address'),
vtype: 'IPAddress', vtype: 'IP64Address',
allowBlank: false allowBlank: false
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment