Skip to content

Commit 05b60ed

Browse files
committed
fix: complete SSH config ProxyJump support for file transfer commands
Completes the SSH config ProxyJump integration for the upload and download CLI commands by adding ssh_config to FileTransferParams. Changes: - Add ssh_config field to FileTransferParams struct in upload.rs - Update dispatcher.rs to pass ctx.ssh_config in FileTransferParams for both upload and download commands - Update upload_file() to call executor.with_ssh_config() - Update download_file() to call executor.with_ssh_config() - Update download_dir_from_node() call to pass params.ssh_config This ensures that `bssh upload` and `bssh download` commands now properly respect ProxyJump directives from ~/.ssh/config.
1 parent 5c000f3 commit 05b60ed

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/app/dispatcher.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub async fn dispatch_command(cli: &Cli, ctx: &AppContext) -> Result<()> {
114114
use_agent: cli.use_agent,
115115
use_password: cli.password,
116116
recursive: *recursive,
117+
ssh_config: Some(&ctx.ssh_config),
117118
};
118119
upload_file(params, source, destination).await
119120
}
@@ -138,6 +139,7 @@ pub async fn dispatch_command(cli: &Cli, ctx: &AppContext) -> Result<()> {
138139
use_agent: cli.use_agent,
139140
use_password: cli.password,
140141
recursive: *recursive,
142+
ssh_config: Some(&ctx.ssh_config),
141143
};
142144
download_file(params, source, destination).await
143145
}

src/commands/download.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,17 @@ pub async fn download_file(
4949
}
5050

5151
let key_path_str = params.key_path.map(|p| p.to_string_lossy().to_string());
52-
let executor = ParallelExecutor::new_with_all_options(
52+
let mut executor = ParallelExecutor::new_with_all_options(
5353
params.nodes.clone(),
5454
params.max_parallel,
5555
key_path_str.clone(),
5656
params.strict_mode,
5757
params.use_agent,
5858
params.use_password,
5959
);
60+
if let Some(ssh_config) = params.ssh_config {
61+
executor = executor.with_ssh_config(Some(ssh_config.clone()));
62+
}
6063

6164
// Check if source contains glob pattern
6265
let has_glob = validated_source.contains('*')
@@ -106,7 +109,6 @@ pub async fn download_file(
106109
);
107110

108111
// Use the download_dir_from_node function directly
109-
// Note: ssh_config is not passed here yet; will be added when FileTransferParams includes it
110112
let result = executor::download_dir_from_node(
111113
node.clone(),
112114
&validated_source,
@@ -115,9 +117,9 @@ pub async fn download_file(
115117
params.strict_mode,
116118
params.use_agent,
117119
params.use_password,
118-
None, // No jump hosts from this code path yet
120+
None, // No jump hosts from this code path (ssh_config handles ProxyJump)
119121
None, // Use default connect timeout
120-
None, // TODO: Add ssh_config support to FileTransferParams
122+
params.ssh_config, // Pass ssh_config for ProxyJump resolution
121123
)
122124
.await;
123125

src/commands/upload.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::path::Path;
1919
use crate::executor::ParallelExecutor;
2020
use crate::node::Node;
2121
use crate::ssh::known_hosts::StrictHostKeyChecking;
22+
use crate::ssh::SshConfig;
2223
use crate::ui::OutputFormatter;
2324
use crate::utils::fs::{format_bytes, resolve_source_files};
2425

@@ -30,6 +31,7 @@ pub struct FileTransferParams<'a> {
3031
pub use_agent: bool,
3132
pub use_password: bool,
3233
pub recursive: bool,
34+
pub ssh_config: Option<&'a SshConfig>,
3335
}
3436

3537
pub async fn upload_file(
@@ -76,14 +78,17 @@ pub async fn upload_file(
7678
);
7779

7880
let key_path_str = params.key_path.map(|p| p.to_string_lossy().to_string());
79-
let executor = ParallelExecutor::new_with_all_options(
81+
let mut executor = ParallelExecutor::new_with_all_options(
8082
params.nodes.clone(),
8183
params.max_parallel,
8284
key_path_str.clone(),
8385
params.strict_mode,
8486
params.use_agent,
8587
params.use_password,
8688
);
89+
if let Some(ssh_config) = params.ssh_config {
90+
executor = executor.with_ssh_config(Some(ssh_config.clone()));
91+
}
8792

8893
let mut total_success = 0;
8994
let mut total_failed = 0;

0 commit comments

Comments
 (0)