[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

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 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).
- If SSH connection timeout is 0, the connection won't timeout.

View File

@@ -524,8 +524,10 @@ mod tests {
#[test]
fn test_config_serialization_theme_serialize() {
let mut theme: Theme = Theme::default();
theme.auth_address = Color::Rgb(240, 240, 240);
let mut theme: Theme = Theme {
auth_address: Color::Rgb(240, 240, 240),
..Default::default()
};
let tmpfile: tempfile::NamedTempFile = tempfile::NamedTempFile::new().unwrap();
let (reader, writer) = create_file_ioers(tmpfile.path());
assert!(serialize(&theme, Box::new(writer)).is_ok());

View File

@@ -315,8 +315,11 @@ mod tests {
#[test]
fn test_fs_explorer_stack() {
let mut explorer: FileExplorer = FileExplorer::default();
explorer.stack_size = 2;
let mut explorer = FileExplorer {
stack_size: 2,
dirstack: VecDeque::with_capacity(2),
..Default::default()
};
explorer.dirstack = VecDeque::with_capacity(2);
// Push dir
explorer.pushd(Path::new("/tmp"));

View File

@@ -159,16 +159,26 @@ impl Builder {
let mut opts = SshOpts::new(params.address.clone())
.key_storage(Box::new(Self::make_ssh_storage(config_client)))
.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
if let Some(username) = params.username {
opts = opts.username(username);
} else if let Some(ssh_config) = config_client.get_ssh_config().and_then(|x| {
//* case 2: found in ssh2 config
debug!("reading ssh config at {}", x);
ssh_utils::parse_ssh2_config(x).ok()
}) {
} else if let Some(ssh_config) = &ssh_config {
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}");
opts = opts.username(username);
} else {

View File

@@ -7,7 +7,7 @@ pub mod auto_update;
pub mod bookmarks_client;
pub mod config_client;
pub mod environment;
pub(self) mod keys;
mod keys;
pub mod logging;
pub mod notifications;
pub mod sshkey_storage;

View File

@@ -3,11 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
use remotefs::fs::UnixPex;
pub(self) use remotefs::File;
use remotefs::File;
use tuirealm::{State, StateValue};
pub(self) use super::browser::FileExplorerTab;
pub(self) use super::{
use super::browser::FileExplorerTab;
use super::{
FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts,
TransferPayload, UiMsg,
};

View File

@@ -18,11 +18,11 @@ use std::time::Duration;
// Includes
use chrono::{DateTime, Local};
pub(self) use lib::browser;
use lib::browser;
use lib::browser::Browser;
use lib::transfer::{TransferOpts, TransferStates};
use remotefs::RemoteFs;
pub(self) use session::TransferPayload;
use session::TransferPayload;
use tempfile::TempDir;
use tuirealm::{Application, EventListenerCfg, NoUserEvent};