Skip to content

Commit 1541fe5

Browse files
samuelaEugeny
authored andcommitted
Analogous keepalive fixes to the client module
1 parent 8a46833 commit 1541fe5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

russh/src/client/encrypted.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ impl Session {
605605
Ok((client, self))
606606
}
607607
_ => {
608-
self.common.received_data = false;
609608
let wants_reply = r.read_byte().map_err(crate::Error::from)?;
610609
if wants_reply == 1 {
611610
if let Some(ref mut enc) = self.common.encrypted {
@@ -705,7 +704,6 @@ impl Session {
705704
push_packet!(enc.write, enc.write.push(msg::REQUEST_FAILURE))
706705
}
707706
}
708-
self.common.received_data = false;
709707
Ok((client, self))
710708
}
711709
Some(&msg::CHANNEL_SUCCESS) => {
@@ -828,7 +826,6 @@ impl Session {
828826
Ok((client, self))
829827
}
830828
_ => {
831-
self.common.received_data = false;
832829
info!("Unhandled packet: {:?}", buf);
833830
Ok((client, self))
834831
}

russh/src/client/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,14 @@ impl Session {
858858
}
859859
}
860860

861+
if self.common.received_data {
862+
// Reset the number of failed keepalive attempts. We don't
863+
// bother detecting keepalive response messages specifically
864+
// (OpenSSH_9.6p1 responds with REQUEST_FAILURE aka 82). Instead
865+
// we assume that the server is still alive if we receive any
866+
// data from it.
867+
self.common.alive_timeouts = 0;
868+
}
861869
if self.common.received_data || sent_keepalive {
862870
if let (futures::future::Either::Right(ref mut sleep), Some(d)) = (
863871
keepalive_timer.as_mut().as_pin_mut(),

0 commit comments

Comments
 (0)