* [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve ipv6/ports for remotes gui @ 2020-10-01 7:57 Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes Dominik Csapak ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Dominik Csapak @ 2020-10-01 7:57 UTC (permalink / raw) To: pbs-devel by using regex to parse out the port and only show it optionally widget-toolkit: Dominik Csapak (2): Utils: improve matching groups of ip/host regexes Toolkit: add HostPort vtype src/Toolkit.js | 8 ++++++++ src/Utils.js | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) proxmox-backup: Dominik Csapak (2): ui: RemoteView: improve host columns ui: RemoteEdit: remove port field and parse it from host field www/config/RemoteView.js | 11 +++++--- www/window/RemoteEdit.js | 58 ++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 12 deletions(-) -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes 2020-10-01 7:57 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve ipv6/ports for remotes gui Dominik Csapak @ 2020-10-01 7:57 ` Dominik Csapak 2020-10-01 8:10 ` [pbs-devel] applied: " Dietmar Maurer 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 2/2] Toolkit: add HostPort vtype Dominik Csapak ` (2 subsequent siblings) 3 siblings, 1 reply; 7+ messages in thread From: Dominik Csapak @ 2020-10-01 7:57 UTC (permalink / raw) To: pbs-devel we only ever want to match the whole hostname/ip, never just some part of it and we do not want to have the ':' as part of the port Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- src/Utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index 8595cce..232c97c 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -873,12 +873,12 @@ utilities: { me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$"); me.IP64_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + "/" + IPV6_CIDR_MASK + ")|(?:" + IPV4_REGEXP + "/" + IPV4_CIDR_MASK + ")$"); - let DnsName_REGEXP = "(?:(([a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*([A-Za-z0-9]([A-Za-z0-9\\-]*[A-Za-z0-9])?))"; + let DnsName_REGEXP = "(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*(?:[A-Za-z0-9](?:[A-Za-z0-9\\-]*[A-Za-z0-9])?))"; me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$"); - me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$"); - me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$"); - me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$"); + me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(?::(\\d+))?$"); + me.HostPortBrackets_match = new RegExp("^\\[(" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](?::(\\d+))?$"); + me.IP6_dotnotation_match = new RegExp("^(" + IPV6_REGEXP + ")(?:\\.(\\d+))?$"); me.Vlan_match = /^vlan(\\d+)/; me.VlanInterface_match = /(\\w+)\\.(\\d+)/; }, -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] applied: [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes Dominik Csapak @ 2020-10-01 8:10 ` Dietmar Maurer 0 siblings, 0 replies; 7+ messages in thread From: Dietmar Maurer @ 2020-10-01 8:10 UTC (permalink / raw) To: Proxmox Backup Server development discussion, Dominik Csapak applied both patches ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH widget-toolkit 2/2] Toolkit: add HostPort vtype 2020-10-01 7:57 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve ipv6/ports for remotes gui Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes Dominik Csapak @ 2020-10-01 7:57 ` Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 1/2] ui: RemoteView: improve host columns Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: RemoteEdit: remove port field and parse it from host field Dominik Csapak 3 siblings, 0 replies; 7+ messages in thread From: Dominik Csapak @ 2020-10-01 7:57 UTC (permalink / raw) To: pbs-devel for easy checking textfield for a single host:port Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- src/Toolkit.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Toolkit.js b/src/Toolkit.js index d528ea7..f706036 100644 --- a/src/Toolkit.js +++ b/src/Toolkit.js @@ -147,6 +147,14 @@ Ext.apply(Ext.form.field.VTypes, { }, DnsOrIpText: gettext('Not a valid DNS name or IP address.'), + HostPort: function(v) { + return Proxmox.Utils.HostPort_match.test(v) || + Proxmox.Utils.HostPortBrackets_match.test(v) || + Proxmox.Utils.IP6_dotnotation_match.test(v); + }, + + HostPortText: gettext('Not a valid hosts'), + HostList: function(v) { let list = v.split(/[ ,;]+/); let i; -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 1/2] ui: RemoteView: improve host columns 2020-10-01 7:57 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve ipv6/ports for remotes gui Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 2/2] Toolkit: add HostPort vtype Dominik Csapak @ 2020-10-01 7:57 ` Dominik Csapak 2020-10-01 8:12 ` [pbs-devel] applied: " Dietmar Maurer 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: RemoteEdit: remove port field and parse it from host field Dominik Csapak 3 siblings, 1 reply; 7+ messages in thread From: Dominik Csapak @ 2020-10-01 7:57 UTC (permalink / raw) To: pbs-devel do not show the default (8007) port and only add brackets [] to ipv6 addresses if there is a port Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- www/config/RemoteView.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/www/config/RemoteView.js b/www/config/RemoteView.js index 96788fc7..98f72bb5 100644 --- a/www/config/RemoteView.js +++ b/www/config/RemoteView.js @@ -4,12 +4,15 @@ Ext.define('pmx-remotes', { { name: 'server', calculate: function(data) { - let host = data.host || "localhost"; + let txt = data.host || "localhost"; let port = data.port || "8007"; - if (Proxmox.Utils.IP64_match.test(host)) { - host = `[${host}]`; + if (port.toString() !== "8007") { + if (Proxmox.Utils.IP6_match.test(txt)) { + txt = `[${txt}]`; + } + txt += `:${port}`; } - return `${host}:${port}`; + return txt; } } ], -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup 1/2] ui: RemoteView: improve host columns 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 1/2] ui: RemoteView: improve host columns Dominik Csapak @ 2020-10-01 8:12 ` Dietmar Maurer 0 siblings, 0 replies; 7+ messages in thread From: Dietmar Maurer @ 2020-10-01 8:12 UTC (permalink / raw) To: Proxmox Backup Server development discussion, Dominik Csapak applied both patches ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 2/2] ui: RemoteEdit: remove port field and parse it from host field 2020-10-01 7:57 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve ipv6/ports for remotes gui Dominik Csapak ` (2 preceding siblings ...) 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 1/2] ui: RemoteView: improve host columns Dominik Csapak @ 2020-10-01 7:57 ` Dominik Csapak 3 siblings, 0 replies; 7+ messages in thread From: Dominik Csapak @ 2020-10-01 7:57 UTC (permalink / raw) To: pbs-devel use our hostport regexes to parse out a potential port from the host field and send it individually this makes for a simpler and cleaner ui this additionally checks the field for valid input before sending it to the backend Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- www/window/RemoteEdit.js | 58 ++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/www/window/RemoteEdit.js b/www/window/RemoteEdit.js index 7d0ea546..bf5c11fc 100644 --- a/www/window/RemoteEdit.js +++ b/www/window/RemoteEdit.js @@ -45,18 +45,45 @@ Ext.define('PBS.window.RemoteEdit', { { xtype: 'proxmoxtextfield', allowBlank: false, - name: 'host', + name: 'hostport', + submitValue: false, + vtype: 'HostPort', fieldLabel: gettext('Host'), + listeners: { + change: function(field, newvalue) { + let host = newvalue; + let port; + + let match = Proxmox.Utils.HostPort_match.exec(newvalue); + if (match === null) { + match = Proxmox.Utils.HostPortBrackets_match.exec(newvalue); + if (match === null) { + match = Proxmox.Utils.IP6_dotnotation_match.exec(newvalue); + } + } + + if (match !== null) { + host = match[1]; + if (match[2] !== undefined) { + port = match[2]; + } + } + + field.up('inputpanel').down('field[name=host]').setValue(host); + field.up('inputpanel').down('field[name=port]').setValue(port); + } + } }, { - xtype: 'proxmoxintegerfield', - allowBlank: true, - minValue: 1, - maxValue: 2**16, - name: 'port', - emptyText: 8007, + xtype: 'proxmoxtextfield', + hidden: true, + name: 'host', + }, + { + xtype: 'proxmoxtextfield', + hidden: true, deleteEmpty: true, - fieldLabel: gettext('Port'), + name: 'port', }, ], @@ -95,6 +122,21 @@ Ext.define('PBS.window.RemoteEdit', { ], }, + setValues: function(values) { + let me = this; + + let host = values.host; + if (values.port !== undefined) { + if (Proxmox.Utils.IP6_match.test(host)) { + host = `[${host}]`; + } + host += `:${values.port}`; + } + values.hostport = host; + + return me.callParent([values]); + }, + getValues: function() { let me = this; let values = me.callParent(arguments); -- 2.20.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-10-01 8:13 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-10-01 7:57 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve ipv6/ports for remotes gui Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 1/2] Utils: improve matching groups of ip/host regexes Dominik Csapak 2020-10-01 8:10 ` [pbs-devel] applied: " Dietmar Maurer 2020-10-01 7:57 ` [pbs-devel] [PATCH widget-toolkit 2/2] Toolkit: add HostPort vtype Dominik Csapak 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 1/2] ui: RemoteView: improve host columns Dominik Csapak 2020-10-01 8:12 ` [pbs-devel] applied: " Dietmar Maurer 2020-10-01 7:57 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: RemoteEdit: remove port field and parse it from host field Dominik Csapak
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