Skip to content

Commit

Permalink
with-ssh - Version update
Browse files Browse the repository at this point in the history
  • Loading branch information
amigin committed Dec 6, 2024
1 parent c339569 commit b834a73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down
21 changes: 20 additions & 1 deletion src/fl_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand Down

0 comments on commit b834a73

Please sign in to comment.