From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <w.bumiller@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 3A66C6360A
 for <pve-devel@lists.proxmox.com>; Wed, 25 Nov 2020 09:42:01 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 25F2C16672
 for <pve-devel@lists.proxmox.com>; Wed, 25 Nov 2020 09:41:31 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 90E9216665
 for <pve-devel@lists.proxmox.com>; Wed, 25 Nov 2020 09:41:30 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5669D44259
 for <pve-devel@lists.proxmox.com>; Wed, 25 Nov 2020 09:41:30 +0100 (CET)
Date: Wed, 25 Nov 2020 09:41:18 +0100 (CET)
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>,
 Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Message-ID: <741497194.403.1606293678845@webmail.proxmox.com>
In-Reply-To: <a6c7366f-8279-148f-6fdb-d1fbbc691f8d@proxmox.com>
References: <20201125081642.27797-1-w.bumiller@proxmox.com>
 <a6c7366f-8279-148f-6fdb-d1fbbc691f8d@proxmox.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer v7.10.4-Rev13
X-Originating-Client: open-xchange-appsuite
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.022 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH manager] ad #3140: allow interface suffix in
 dns entries
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 25 Nov 2020 08:42:01 -0000

> 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',
> >