From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CB6B91FF141 for ; Tue, 19 May 2026 21:07:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0AFD9104A5; Tue, 19 May 2026 21:06:55 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH network] sdn: fabrics: split WireGuard endpoint port field Date: Tue, 19 May 2026 21:06:32 +0200 Message-ID: <20260519190645.265484-1-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1779217595634 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: JQBRPYVYUJ5KUJZNJ7RPHDFQM553JVIA X-Message-ID-Hash: JQBRPYVYUJ5KUJZNJ7RPHDFQM553JVIA X-MailFrom: g.goller@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Expose the WireGuard endpoint port as a separate optional field in the node edit window, defaulting to the standard WireGuard port 51820. Keep the API representation unchanged by splitting endpoint host and port on load, and combining them again on submit. Wrap IPv6 addresses in brackets when adding the port. Signed-off-by: Gabriel Goller --- This makes the validation easier. Also endpoint ports are not optional anymore. I know the "send default value to api" is not really pretty, but I think this a convenience default anyway + changing this in the backend is a bit tricky because we pull the generic `ServiceEndpoint` through the whole api. .../sdn/fabrics/wireguard/NodeEdit.js | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/www/manager6/sdn/fabrics/wireguard/NodeEdit.js b/www/manager6/sdn/fabrics/wireguard/NodeEdit.js index ba5899cb9f1b..0943ac5a35ae 100644 --- a/www/manager6/sdn/fabrics/wireguard/NodeEdit.js +++ b/www/manager6/sdn/fabrics/wireguard/NodeEdit.js @@ -13,6 +13,8 @@ Ext.define('PVE.sdn.Fabric.WireGuard.Node.Edit', { hasIpv4Support: false, hasIpv6Support: false, + defaultEndpointPort: 51820, + viewModel: { data: { current: { @@ -58,11 +60,22 @@ Ext.define('PVE.sdn.Fabric.WireGuard.Node.Edit', { { xtype: 'proxmoxtextfield', fieldLabel: gettext('Endpoint'), - emptyText: gettext('Host or host:port that peers connect to'), + emptyText: gettext('Host that peers connect to'), labelWidth: 120, name: 'endpoint', allowBlank: false, }, + { + xtype: 'proxmoxintegerfield', + fieldLabel: gettext('Endpoint Port'), + emptyText: gettext('Default') + ': 51820', + labelWidth: 120, + name: 'endpoint_port', + minValue: 1, + maxValue: 65535, + allowBlank: true, + submitValue: false, + }, { xtype: 'proxmoxtextfield', fieldLabel: gettext('Allowed IPs'), @@ -95,6 +108,45 @@ Ext.define('PVE.sdn.Fabric.WireGuard.Node.Edit', { }, ], + combineEndpoint: function (endpoint, port) { + let me = this; + + port = port || me.defaultEndpointPort; + + if (Proxmox.Utils.IP6_match.test(endpoint)) { + endpoint = `[${endpoint}]`; + } + + return `${endpoint}:${port}`; + }, + + splitEndpoint: function (endpoint) { + let match = endpoint?.match(/^\[([^\]]+)\]:(\d+)$/) ?? endpoint?.match(/^([^:]+):(\d+)$/); + if (!match) { + return { endpoint }; + } + + return { + endpoint: match[1], + endpoint_port: Number(match[2]), + }; + }, + + getValues: function (dirtyOnly) { + let me = this; + + let values = me.callParent([dirtyOnly]); + let endpointField = me.down('[name=endpoint]'); + let portField = me.down('[name=endpoint_port]'); + + if (!dirtyOnly || values.endpoint || portField.isDirty()) { + values.endpoint = me.combineEndpoint(endpointField.getValue(), portField.getValue()); + } + delete values.endpoint_port; + + return values; + }, + loadAvailablePeers: async function () { let me = this; @@ -141,6 +193,7 @@ Ext.define('PVE.sdn.Fabric.WireGuard.Node.Edit', { .then(([node, availablePeers]) => { me.interfaceSelector.setAvailablePeers(availablePeers); + Ext.apply(node, me.splitEndpoint(node.endpoint)); node.interfaces = node.interfaces ?? []; node.peers = node.peers ?? []; me.interfaceSelector.setNode(node); -- 2.47.3