Skip to content

Commit 3eb117c

Browse files
committed
chore: Fix lint warnings, format code, and update documentation
- Add #[allow(clippy::too_many_arguments)] for establish_connection function - Apply cargo fmt formatting fixes - Add interactive mode + keepalive example to README and manpage
1 parent f91c469 commit 3eb117c

7 files changed

Lines changed: 26 additions & 13 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,9 @@ bssh -H server1,server2 interactive --prompt-format "{user}@{host}> "
12411241

12421242
# Set initial working directory
12431243
bssh -C staging interactive --work-dir /var/www
1244+
1245+
# Interactive mode with keepalive for long-running sessions (e.g., tmux)
1246+
bssh -C production --server-alive-interval 30 --server-alive-count-max 5 interactive
12441247
```
12451248

12461249
#### Interactive Mode Configuration

docs/man/bssh.1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,14 @@ Interactive mode with initial working directory:
15811581
Sets initial working directory to /var/www on all nodes
15821582
.RE
15831583

1584+
.TP
1585+
Interactive mode with keepalive for long-running sessions:
1586+
.B bssh -C production --server-alive-interval 30 --server-alive-count-max 5 interactive
1587+
.RS
1588+
Configure SSH keepalive settings to prevent idle disconnection in long-running sessions (e.g., tmux).
1589+
The keepalive settings apply to both the destination host and any jump hosts in the connection chain.
1590+
.RE
1591+
15841592
.SS Exit Code Handling Examples (v1.2.0+)
15851593

15861594
.TP

src/commands/interactive/connection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl InteractiveCommand {
3939
/// and retry with password authentication (matching OpenSSH behavior).
4040
///
4141
/// The `ssh_config` parameter allows configuring SSH connection settings like keepalive intervals.
42+
#[allow(clippy::too_many_arguments)]
4243
async fn establish_connection(
4344
addr: (&str, u16),
4445
username: &str,

src/pty/session/session_manager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ impl PtySession {
301301

302302
// Track last activity time for connection health monitoring
303303
let mut last_activity = std::time::Instant::now();
304-
let health_check_interval =
305-
Duration::from_secs(CONNECTION_HEALTH_CHECK_INTERVAL_SECS);
304+
let health_check_interval = Duration::from_secs(CONNECTION_HEALTH_CHECK_INTERVAL_SECS);
306305
let max_idle_time = Duration::from_secs(MAX_IDLE_TIME_BEFORE_WARNING_SECS);
307306
let mut idle_warning_shown = false;
308307

src/ssh/ssh_config/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,10 @@ impl SshConfig {
212212
{
213213
// Check if there's at least a matching host pattern
214214
// If not, this alias doesn't exist in SSH config
215-
let has_matching_pattern = self.hosts.iter().any(|h| {
216-
h.host_patterns
217-
.iter()
218-
.any(|p| p == host_alias || p == "*")
219-
});
215+
let has_matching_pattern = self
216+
.hosts
217+
.iter()
218+
.any(|h| h.host_patterns.iter().any(|p| p == host_alias || p == "*"));
220219

221220
if !has_matching_pattern {
222221
return None;

tests/jump_host_config_test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,12 @@ clusters:
690690
.unwrap()
691691
.is_ssh_config_ref());
692692
assert_eq!(
693-
cluster.defaults.jump_host.as_ref().unwrap().ssh_config_host(),
693+
cluster
694+
.defaults
695+
.jump_host
696+
.as_ref()
697+
.unwrap()
698+
.ssh_config_host(),
694699
Some("bastion")
695700
);
696701
}

tests/ssh_keepalive_test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,7 @@ fn test_interactive_mode_ssh_connection_config_default() {
683683
"InteractiveCommand should have default keepalive interval"
684684
);
685685
assert_eq!(
686-
cmd.ssh_connection_config.keepalive_max,
687-
DEFAULT_KEEPALIVE_MAX,
686+
cmd.ssh_connection_config.keepalive_max, DEFAULT_KEEPALIVE_MAX,
688687
"InteractiveCommand should have default keepalive max"
689688
);
690689
}
@@ -806,17 +805,16 @@ fn test_jump_host_chain_with_ssh_connection_config() {
806805
.with_keepalive_max(5);
807806

808807
// JumpHostChain should accept the config via builder pattern
809-
let _chain = JumpHostChain::direct()
810-
.with_ssh_connection_config(ssh_config);
808+
let _chain = JumpHostChain::direct().with_ssh_connection_config(ssh_config);
811809

812810
// If we got here without panicking, the config was accepted correctly
813811
}
814812

815813
#[test]
816814
fn test_jump_host_chain_with_custom_keepalive_for_long_running_sessions() {
817815
// Test real-world use case: long-running sessions need longer keepalive
818-
use bssh::jump::JumpHostChain;
819816
use bssh::jump::parser::JumpHost;
817+
use bssh::jump::JumpHostChain;
820818
use std::time::Duration;
821819

822820
// For long-running interactive sessions, use longer keepalive intervals

0 commit comments

Comments
 (0)