all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v3 manager] ad #3140: allow interface suffix in dns entries
@ 2020-11-25 10:36 Wolfgang Bumiller
  2020-11-25 11:08 ` Dietmar Maurer
  2020-11-25 12:31 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 9+ messages in thread
From: Wolfgang Bumiller @ 2020-11-25 10:36 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
changes to v2:
* use `for of` loop in verify_ip64_address_list

 www/manager6/Toolkit.js | 17 ++---------------
 www/manager6/Utils.js   | 27 +++++++++++++++++++++++++++
 www/manager6/lxc/DNS.js |  2 +-
 3 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index 55b127c5..0569d649 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -9,21 +9,8 @@ Ext.apply(Ext.form.field.VTypes, {
 	return (/^(now|\d{4}-\d{1,2}-\d{1,2}(T\d{1,2}:\d{1,2}:\d{1,2})?)$/).test(v);
     },
     QemuStartDateText: gettext('Format') + ': "now" or "2006-06-17T16:01:21" or "2006-06-17"',
-    IP64AddressList: function(v) {
-	var list = v.split(/[\ \,\;]+/);
-	var i;
-	for (i = 0; i < list.length; i++) {
-	    if (list[i] == '') {
-		continue;
-	    }
-
-	    if (!Proxmox.Utils.IP64_match.test(list[i])) {
-		return false;
-	    }
-	}
-
-	return true;
-    },
+    IP64AddressList: v => PVE.Utils.verify_ip64_address_list(v, false),
+    IP64AddressWithSuffixList: v => PVE.Utils.verify_ip64_address_list(v, true),
     IP64AddressListText: gettext('Example') + ': 192.168.1.1,192.168.1.2',
     IP64AddressListMask: /[A-Fa-f0-9\,\:\.\;\ ]/
 });
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 6d2f7a04..6e6498a2 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1612,6 +1612,33 @@ Ext.define('PVE.Utils', { utilities: {
 	"Host": 4,
 	"_default_": 5, // includes custom models
     },
+
+    verify_ip64_address_list: function(value, with_suffix) {
+	for (let addr of value.split(/[ ,;]+/)) {
+	    if (addr === '') {
+		continue;
+	    }
+
+	    if (with_suffix) {
+		let parts = addr.split('%');
+		addr = parts[0];
+
+		if (parts.length > 2) {
+		    return false;
+		}
+
+		if (parts.length > 1 && !addr.startsWith('fe80:')) {
+		    return false;
+		}
+	    }
+
+	    if (!Proxmox.Utils.IP64_match.test(addr)) {
+		return false;
+	    }
+	}
+
+	return true;
+    },
 },
 
     singleton: true,
diff --git a/www/manager6/lxc/DNS.js b/www/manager6/lxc/DNS.js
index a15db5a9..b1e03920 100644
--- a/www/manager6/lxc/DNS.js
+++ b/www/manager6/lxc/DNS.js
@@ -41,7 +41,7 @@ Ext.define('PVE.lxc.DNSInputPanel', {
 	    {
 		xtype: 'proxmoxtextfield',
 		fieldLabel: gettext('DNS servers'),
-		vtype: 'IP64AddressList',
+		vtype: 'IP64AddressWithSuffixList',
 		allowBlank: true,
 		emptyText: gettext('use host settings'),
 		name: 'nameserver',
-- 
2.20.1





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-25 12:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 10:36 [pve-devel] [PATCH v3 manager] ad #3140: allow interface suffix in dns entries Wolfgang Bumiller
2020-11-25 11:08 ` Dietmar Maurer
2020-11-25 11:22   ` Dietmar Maurer
2020-11-25 11:34     ` Wolfgang Bumiller
2020-11-25 11:39       ` Dietmar Maurer
2020-11-25 11:51         ` Wolfgang Bumiller
2020-11-25 11:57           ` Dietmar Maurer
2020-11-25 11:22   ` Stoiko Ivanov
2020-11-25 12:31 ` [pve-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal