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}`; } }