Skip to content

Commit

Permalink
Upgrade ssh2-config to 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
whme committed May 31, 2024
1 parent 0f4453d commit 71e532d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
31 changes: 25 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rmp = "0.8.11"
serde = "1.0.163"
serde_derive = "1.0.163"
simplelog = "0.12.2"
ssh2-config = "0.1.6"
ssh2-config = "0.2.3"
time = "0.3.36"
tokio = { version = "1.36.0", features = ["rt", "rt-multi-thread", "net", "sync", "macros", "time", "signal", "process"] }

Expand Down
9 changes: 3 additions & 6 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use windows::Win32::UI::Input::KeyboardAndMouse::VK_C;
use crate::utils::config::ClientConfig;
use crate::utils::constants::DEFAULT_SSH_USERNAME_KEY;
use crate::utils::{get_console_input_buffer, get_console_title, set_console_title};
use ssh2_config::SshConfig;
use ssh2_config::{ParseRule, SshConfig};
use tokio::net::windows::named_pipe::NamedPipeClient;
use tokio::process::{Child, Command};
use tokio::{io::Interest, net::windows::named_pipe::ClientOptions};
Expand Down Expand Up @@ -75,18 +75,15 @@ fn get_username_and_host(username: &str, host: &str, config: &ClientConfig) -> S
File::open(ssh_config_path).expect("Could not open SSH configuration file."),
);
ssh_config = SshConfig::default()
.parse(&mut reader)
.parse(&mut reader, ParseRule::ALLOW_UNKNOWN_FIELDS)
.expect("Failed to parse SSH configuration file");
}

let default_params = ssh_config.default_params();
let host_specific_params = ssh_config.query(<&str>::clone(&host));

let username: String = if username == DEFAULT_SSH_USERNAME_KEY {
// FIXME: find a better default
host_specific_params
.user
.unwrap_or(default_params.user.unwrap_or("undefined".to_string()))
host_specific_params.user.unwrap_or_default()
} else {
username.to_owned()
};
Expand Down

0 comments on commit 71e532d

Please sign in to comment.