Skip to content

Commit

Permalink
feat: support non-standard ssh clients and passthrough options
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyscot committed Oct 25, 2024
1 parent fd7aab7 commit 7e351f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) struct CliArgs {
/// intended for interactive use.
#[arg(
long, help_heading("Modes"), hide = true,
conflicts_with_all(["help_buffers", "quiet", "statistics", "timeout", "ipv4", "ipv6", "remote_debug", "profile"])
conflicts_with_all(["help_buffers", "quiet", "statistics", "timeout", "ipv4", "ipv6", "remote_debug", "profile", "source", "destination", "ssh", "ssh_opt"])
)]
pub server: bool,

Expand Down Expand Up @@ -71,6 +71,21 @@ pub(crate) struct CliArgs {
#[arg(short = '6', long, action, conflicts_with("ipv4"))]
pub ipv6: bool,

/// Specifies the ssh client program to use
#[arg(long, default_value("ssh"))]
pub ssh: String,

/// Specifies an additional option or argument to pass to the ssh client.
/// Note: you must repeat `-S` for each.
/// For example, to pass `-i /dev/null` to ssh, specify `-S -i -S /dev/null`
#[arg(
short = 'S',
action,
value_name("ssh-option"),
allow_hyphen_values(true)
)]
pub ssh_opt: Vec<String>,

// CLIENT DEBUG ----------------------------
/// Enable detailed debug output
#[arg(short, long, action, help_heading("Debug options"), display_order(100))]
Expand Down
7 changes: 6 additions & 1 deletion src/client/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct Parameters {
bbr: bool,
iwind: Option<u64>,
family: AddressFamily,
ssh_client: String,
ssh_opts: Vec<String>,
}

impl TryFrom<&CliArgs> for Parameters {
Expand All @@ -43,6 +45,8 @@ impl TryFrom<&CliArgs> for Parameters {
bbr: args.bbr,
iwind: args.initial_congestion_window,
family: args.address_family(),
ssh_client: args.ssh.clone(),
ssh_opts: args.ssh_opt.clone(),
})
}
}
Expand Down Expand Up @@ -93,13 +97,14 @@ impl ControlChannel {

/// This is effectively a constructor. At present, it launches a subprocess.
fn launch(args: &Parameters) -> Result<Self> {
let mut server = tokio::process::Command::new("ssh");
let mut server = tokio::process::Command::new(&args.ssh_client);
let _ = server.kill_on_drop(true);
let _ = match args.family {
AddressFamily::Any => &mut server,
AddressFamily::IPv4 => server.arg("-4"),
AddressFamily::IPv6 => server.arg("-6"),
};
let _ = server.args(&args.ssh_opts);
let _ = server.args([
&args.remote_user_host,
"qcp",
Expand Down

0 comments on commit 7e351f2

Please sign in to comment.