[BUG] - termscp not respecting port in ssh config (#216)

This commit is contained in:
Christian Visintin
2023-10-01 16:12:43 +02:00
committed by GitHub
parent d3c2c084db
commit 20c3e22572
7 changed files with 32 additions and 16 deletions
+1
View File
@@ -38,6 +38,7 @@ Released on 06/07/2023
- [Issue 169](https://github.com/veeso/termscp/issues/169): Local working directory can now be specified in connection form and be saved into bookmarks. - [Issue 169](https://github.com/veeso/termscp/issues/169): Local working directory can now be specified in connection form and be saved into bookmarks.
- [Issue 188](https://github.com/veeso/termscp/issues/188): The breadcrumbs path is not fallbacked after a failed enter into the directory - [Issue 188](https://github.com/veeso/termscp/issues/188): The breadcrumbs path is not fallbacked after a failed enter into the directory
- [Issue 215](https://github.com/veeso/termscp/issues/215): termscp not respecting port in SSH config. The port specified for the host in the SSH configuration wasn't evaluated.
- SMB support is now a feature (you can build rust without default features to disable smb). - SMB support is now a feature (you can build rust without default features to disable smb).
- If SSH connection timeout is 0, the connection won't timeout. - If SSH connection timeout is 0, the connection won't timeout.
+4 -2
View File
@@ -524,8 +524,10 @@ mod tests {
#[test] #[test]
fn test_config_serialization_theme_serialize() { fn test_config_serialization_theme_serialize() {
let mut theme: Theme = Theme::default(); let mut theme: Theme = Theme {
theme.auth_address = Color::Rgb(240, 240, 240); auth_address: Color::Rgb(240, 240, 240),
..Default::default()
};
let tmpfile: tempfile::NamedTempFile = tempfile::NamedTempFile::new().unwrap(); let tmpfile: tempfile::NamedTempFile = tempfile::NamedTempFile::new().unwrap();
let (reader, writer) = create_file_ioers(tmpfile.path()); let (reader, writer) = create_file_ioers(tmpfile.path());
assert!(serialize(&theme, Box::new(writer)).is_ok()); assert!(serialize(&theme, Box::new(writer)).is_ok());
+5 -2
View File
@@ -315,8 +315,11 @@ mod tests {
#[test] #[test]
fn test_fs_explorer_stack() { fn test_fs_explorer_stack() {
let mut explorer: FileExplorer = FileExplorer::default(); let mut explorer = FileExplorer {
explorer.stack_size = 2; stack_size: 2,
dirstack: VecDeque::with_capacity(2),
..Default::default()
};
explorer.dirstack = VecDeque::with_capacity(2); explorer.dirstack = VecDeque::with_capacity(2);
// Push dir // Push dir
explorer.pushd(Path::new("/tmp")); explorer.pushd(Path::new("/tmp"));
+16 -6
View File
@@ -159,16 +159,26 @@ impl Builder {
let mut opts = SshOpts::new(params.address.clone()) let mut opts = SshOpts::new(params.address.clone())
.key_storage(Box::new(Self::make_ssh_storage(config_client))) .key_storage(Box::new(Self::make_ssh_storage(config_client)))
.port(params.port); .port(params.port);
// get ssh config
let ssh_config = config_client
.get_ssh_config()
.and_then(|path| {
debug!("reading ssh config at {}", path);
ssh_utils::parse_ssh2_config(path).ok()
})
.map(|config| config.query(&params.address));
//* override port
if let Some(port) = ssh_config.as_ref().and_then(|config| config.port) {
opts = opts.port(port);
}
//* get username. Case 1 provided in params //* get username. Case 1 provided in params
if let Some(username) = params.username { if let Some(username) = params.username {
opts = opts.username(username); opts = opts.username(username);
} else if let Some(ssh_config) = config_client.get_ssh_config().and_then(|x| { } else if let Some(ssh_config) = &ssh_config {
//* case 2: found in ssh2 config
debug!("reading ssh config at {}", x);
ssh_utils::parse_ssh2_config(x).ok()
}) {
debug!("no username was provided, checking whether a user is set for this host"); debug!("no username was provided, checking whether a user is set for this host");
if let Some(username) = ssh_config.query(&params.address).user { if let Some(username) = &ssh_config.user {
debug!("found username from config: {username}"); debug!("found username from config: {username}");
opts = opts.username(username); opts = opts.username(username);
} else { } else {
+1 -1
View File
@@ -7,7 +7,7 @@ pub mod auto_update;
pub mod bookmarks_client; pub mod bookmarks_client;
pub mod config_client; pub mod config_client;
pub mod environment; pub mod environment;
pub(self) mod keys; mod keys;
pub mod logging; pub mod logging;
pub mod notifications; pub mod notifications;
pub mod sshkey_storage; pub mod sshkey_storage;
@@ -3,11 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
use remotefs::fs::UnixPex; use remotefs::fs::UnixPex;
pub(self) use remotefs::File; use remotefs::File;
use tuirealm::{State, StateValue}; use tuirealm::{State, StateValue};
pub(self) use super::browser::FileExplorerTab; use super::browser::FileExplorerTab;
pub(self) use super::{ use super::{
FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts, FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts,
TransferPayload, UiMsg, TransferPayload, UiMsg,
}; };
+2 -2
View File
@@ -18,11 +18,11 @@ use std::time::Duration;
// Includes // Includes
use chrono::{DateTime, Local}; use chrono::{DateTime, Local};
pub(self) use lib::browser; use lib::browser;
use lib::browser::Browser; use lib::browser::Browser;
use lib::transfer::{TransferOpts, TransferStates}; use lib::transfer::{TransferOpts, TransferStates};
use remotefs::RemoteFs; use remotefs::RemoteFs;
pub(self) use session::TransferPayload; use session::TransferPayload;
use tempfile::TempDir; use tempfile::TempDir;
use tuirealm::{Application, EventListenerCfg, NoUserEvent}; use tuirealm::{Application, EventListenerCfg, NoUserEvent};