* [pve-devel] [PATCH manager] ad #3140: allow interface suffix in dns entries
@ 2020-11-25 8:16 Wolfgang Bumiller
2020-11-25 8:31 ` Dominik Csapak
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Bumiller @ 2020-11-25 8:16 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
patch generated with --histogram diff algorithm
www/manager6/Toolkit.js | 47 ++++++++++++++++++++++++++++-------------
www/manager6/lxc/DNS.js | 2 +-
2 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index 55b127c5..ee48e2ef 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -2,6 +2,36 @@
Proxmox.Utils.toolkit = 'extjs';
+function pve_verify_ip64_address_list(v, with_suffix) {
+ var list = v.split(/[\ \,\;]+/);
+ var i;
+ for (i = 0; i < list.length; i++) {
+ if (list[i] == '') {
+ continue;
+ }
+
+ let addr = list[i];
+ if (with_suffix) {
+ let parts = addr.split('%');
+ addr = parts[0];
+
+ if (parts.length < 1 || 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;
+}
+
// custom PVE specific VTypes
Ext.apply(Ext.form.field.VTypes, {
@@ -9,21 +39,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_verify_ip64_address_list(v, false),
+ IP64AddressWithSuffixList: v => pve_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/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] 3+ messages in thread
* Re: [pve-devel] [PATCH manager] ad #3140: allow interface suffix in dns entries
2020-11-25 8:16 [pve-devel] [PATCH manager] ad #3140: allow interface suffix in dns entries Wolfgang Bumiller
@ 2020-11-25 8:31 ` Dominik Csapak
2020-11-25 8:41 ` Wolfgang Bumiller
0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2020-11-25 8:31 UTC (permalink / raw)
To: Proxmox VE development discussion, Wolfgang Bumiller
hi,
please use 'eslint' to check new javascript code, it
would have caught some things ;)
(though most things were just moved...)
comments inline
On 11/25/20 9:16 AM, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> ---
> patch generated with --histogram diff algorithm
> www/manager6/Toolkit.js | 47 ++++++++++++++++++++++++++++-------------
> www/manager6/lxc/DNS.js | 2 +-
> 2 files changed, 33 insertions(+), 16 deletions(-)
>
> diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
> index 55b127c5..ee48e2ef 100644
> --- a/www/manager6/Toolkit.js
> +++ b/www/manager6/Toolkit.js
> @@ -2,6 +2,36 @@
>
> Proxmox.Utils.toolkit = 'extjs';
>
> +function pve_verify_ip64_address_list(v, with_suffix) {
please do not define global functions, put them in PVE.Utils instead
> + var list = v.split(/[\ \,\;]+/);
i know it's copied, but the escaping is not necessary
> + var i;
> + for (i = 0; i < list.length; i++) {
> + if (list[i] == '') {
same here, please use === instead of ==
> + continue;
> + }
> +
> + let addr = list[i];
> + if (with_suffix) {
> + let parts = addr.split('%');
> + addr = parts[0];
> +
> + if (parts.length < 1 || parts.length > 2) {
nit, split cannot return an empty array, it always returns at least one
element (the original string)
> + return false;
> + }
> +
> + if (parts.length > 1 && !addr.startsWith('fe80:')) {
> + return false;
> + }
> + }
> +
> + if (!Proxmox.Utils.IP64_match.test(addr)) {
> + return false;
> + }
> + }
> +
> + return true;
> +}
> +
> // custom PVE specific VTypes
> Ext.apply(Ext.form.field.VTypes, {
>
> @@ -9,21 +39,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_verify_ip64_address_list(v, false),
> + IP64AddressWithSuffixList: v => pve_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/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',
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH manager] ad #3140: allow interface suffix in dns entries
2020-11-25 8:31 ` Dominik Csapak
@ 2020-11-25 8:41 ` Wolfgang Bumiller
0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2020-11-25 8:41 UTC (permalink / raw)
To: Dominik Csapak, Proxmox VE development discussion
> On 11/25/2020 9:31 AM Dominik Csapak <d.csapak@proxmox.com> wrote:
>
>
> hi,
>
> please use 'eslint' to check new javascript code, it
> would have caught some things ;)
thought we'd be running that at build time, oops
> (though most things were just moved...)
>
> comments inline
>
> On 11/25/20 9:16 AM, Wolfgang Bumiller wrote:
> > Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> > ---
> > patch generated with --histogram diff algorithm
> > www/manager6/Toolkit.js | 47 ++++++++++++++++++++++++++++-------------
> > www/manager6/lxc/DNS.js | 2 +-
> > 2 files changed, 33 insertions(+), 16 deletions(-)
> >
> > diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
> > index 55b127c5..ee48e2ef 100644
> > --- a/www/manager6/Toolkit.js
> > +++ b/www/manager6/Toolkit.js
> > @@ -2,6 +2,36 @@
> >
> > Proxmox.Utils.toolkit = 'extjs';
> >
> > +function pve_verify_ip64_address_list(v, with_suffix) {
>
> please do not define global functions, put them in PVE.Utils instead
>
> > + var list = v.split(/[\ \,\;]+/);
>
> i know it's copied, but the escaping is not necessary
>
> > + var i;
> > + for (i = 0; i < list.length; i++) {
> > + if (list[i] == '') {
>
> same here, please use === instead of ==
>
> > + continue;
> > + }
> > +
> > + let addr = list[i];
> > + if (with_suffix) {
> > + let parts = addr.split('%');
> > + addr = parts[0];
> > +
> > + if (parts.length < 1 || parts.length > 2) {
>
> nit, split cannot return an empty array, it always returns at least one
> element (the original string)
>
>
> > + return false;
> > + }
> > +
> > + if (parts.length > 1 && !addr.startsWith('fe80:')) {
> > + return false;
> > + }
> > + }
> > +
> > + if (!Proxmox.Utils.IP64_match.test(addr)) {
> > + return false;
> > + }
> > + }
> > +
> > + return true;
> > +}
> > +
> > // custom PVE specific VTypes
> > Ext.apply(Ext.form.field.VTypes, {
> >
> > @@ -9,21 +39,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_verify_ip64_address_list(v, false),
> > + IP64AddressWithSuffixList: v => pve_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/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',
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-25 8:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 8:16 [pve-devel] [PATCH manager] ad #3140: allow interface suffix in dns entries Wolfgang Bumiller
2020-11-25 8:31 ` Dominik Csapak
2020-11-25 8:41 ` Wolfgang Bumiller
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