From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C1AAB625FD for ; Wed, 30 Sep 2020 13:24:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B8E7F1861C for ; Wed, 30 Sep 2020 13:23:41 +0200 (CEST) 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 23B1418614 for ; Wed, 30 Sep 2020 13:23:41 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E1030458E9 for ; Wed, 30 Sep 2020 13:23:40 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 30 Sep 2020 13:23:39 +0200 Message-Id: <20200930112339.21487-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.148 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records 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_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pull.rs, data.host] Subject: [pbs-devel] [PATCH proxmox-backup] fix ipv6 handling for remotes/sync jobs X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Sep 2020 11:24:11 -0000 * add square brackets to ipv6 adresses in BackupRepository if they not already have some (we save them without in the remote config) * in get_pull_parameters, we now create a BackupRepository first and use those values (which does the [] mapping), this also has the advantage that we have one place less were we hardcode 8007 as port * in the ui, add square brackets for ipv6 adresses for remotes Signed-off-by: Dominik Csapak --- src/api2/pull.rs | 5 +++-- src/client/backup_repo.rs | 6 ++++++ www/config/RemoteView.js | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api2/pull.rs b/src/api2/pull.rs index 3edbdf2f..c78658b5 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -55,12 +55,13 @@ pub async fn get_pull_parameters( .password(Some(remote.password.clone())) .fingerprint(remote.fingerprint.clone()); - let client = HttpClient::new(&remote.host, remote.port.unwrap_or(8007), &remote.userid, options)?; + let src_repo = BackupRepository::new(Some(remote.userid.clone()), Some(remote.host.clone()), remote.port, remote_store.to_string()); + + let client = HttpClient::new(&src_repo.host(), src_repo.port(), &src_repo.user(), options)?; let _auth_info = client.login() // make sure we can auth .await .map_err(|err| format_err!("remote connection to '{}' failed - {}", remote.host, err))?; - let src_repo = BackupRepository::new(Some(remote.userid), Some(remote.host), remote.port, remote_store.to_string()); Ok((client, src_repo, tgt_store)) } diff --git a/src/client/backup_repo.rs b/src/client/backup_repo.rs index 862e93af..c33314bf 100644 --- a/src/client/backup_repo.rs +++ b/src/client/backup_repo.rs @@ -28,6 +28,12 @@ pub struct BackupRepository { impl BackupRepository { pub fn new(user: Option, host: Option, port: Option, store: String) -> Self { + let host = match host { + Some(host) if (IP_V6_REGEX.regex_obj)().is_match(&host) => { + Some(format!("[{}]", host)) + }, + other => other, + }; Self { user, host, port, store } } diff --git a/www/config/RemoteView.js b/www/config/RemoteView.js index a804e5d6..96788fc7 100644 --- a/www/config/RemoteView.js +++ b/www/config/RemoteView.js @@ -6,6 +6,9 @@ Ext.define('pmx-remotes', { calculate: function(data) { let host = data.host || "localhost"; let port = data.port || "8007"; + if (Proxmox.Utils.IP64_match.test(host)) { + host = `[${host}]`; + } return `${host}:${port}`; } } -- 2.20.1