From b834a73eaa68d2dbe4bf79a240f946b5ef7bcfa5 Mon Sep 17 00:00:00 2001 From: amigin Date: Fri, 6 Dec 2024 18:15:43 +0200 Subject: [PATCH] with-ssh - Version update --- Cargo.toml | 2 +- src/fl_url.rs | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2861ccd..3974431 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ serde = { version = "*", features = ["derive"] } serde_json = { version = "*" } openssl = { version = "*" } -my-ssh = { tag = "0.1.1", git = "https://github.com/MyJetTools/my-ssh.git", optional = true } +my-ssh = { tag = "0.1.2", git = "https://github.com/MyJetTools/my-ssh.git", optional = true } webpki-roots = "*" webpki = "*" diff --git a/src/fl_url.rs b/src/fl_url.rs index e5c4bcc..247c62e 100644 --- a/src/fl_url.rs +++ b/src/fl_url.rs @@ -154,7 +154,7 @@ impl FlUrl { ) -> Self { let ssh_credentials = self.ssh_credentials.take(); if ssh_credentials.is_none() { - panic!("To specify ssh password you need to use ssh://user:password@host:port->http://localhost:8080 connection line"); + return self; } let ssh_credentials = ssh_credentials.unwrap(); @@ -170,6 +170,25 @@ impl FlUrl { self } + #[cfg(feature = "with-ssh")] + pub fn set_ssh_user_password<'s>(mut self, password: String) -> Self { + let ssh_credentials = self.ssh_credentials.take(); + if ssh_credentials.is_none() { + return self; + } + let ssh_credentials = ssh_credentials.unwrap(); + + let (host, port) = ssh_credentials.get_host_port(); + + self.ssh_credentials = Some(my_ssh::SshCredentials::UserNameAndPassword { + ssh_remote_host: host.to_string(), + ssh_remote_port: port, + ssh_user_name: ssh_credentials.get_user_name().to_string(), + password, + }); + self + } + pub fn set_timeout(mut self, timeout: Duration) -> Self { self.execute_timeout = timeout; self