]> git.proxmox.com Git - proxmox-backup.git/commitdiff
fix ipv6 handling for remotes/sync jobs
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 30 Sep 2020 11:23:39 +0000 (13:23 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 30 Sep 2020 11:40:03 +0000 (13:40 +0200)
* 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 <d.csapak@proxmox.com>
src/api2/pull.rs
src/client/backup_repo.rs
www/config/RemoteView.js

index 3edbdf2f072812d5712ee2ca64b085e48cad4d74..c78658b56bf7291e14384ee681872b197f23e497 100644 (file)
@@ -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))
 }
index 862e93af81e2d71063a182455858a5f079ade821..c33314bf21847c1aa0845e868e3ca9a6375fef64 100644 (file)
@@ -28,6 +28,12 @@ pub struct BackupRepository {
 impl BackupRepository {
 
     pub fn new(user: Option<Userid>, host: Option<String>, port: Option<u16>, 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 }
     }
 
index a804e5d6979d9643a61f4aacccdfc9eb6926e665..96788fc747916574146690fba8cf25473fba46c0 100644 (file)
@@ -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}`;
            }
        }