Skip to content

Commit

Permalink
Analogous keepalive fixes to the client module
Browse files Browse the repository at this point in the history
  • Loading branch information
samuela authored and Eugeny committed Feb 7, 2024
1 parent 8a46833 commit 1541fe5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 0 additions & 3 deletions russh/src/client/encrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ impl Session {
Ok((client, self))
}
_ => {
self.common.received_data = false;
let wants_reply = r.read_byte().map_err(crate::Error::from)?;
if wants_reply == 1 {
if let Some(ref mut enc) = self.common.encrypted {
Expand Down Expand Up @@ -705,7 +704,6 @@ impl Session {
push_packet!(enc.write, enc.write.push(msg::REQUEST_FAILURE))
}
}
self.common.received_data = false;
Ok((client, self))
}
Some(&msg::CHANNEL_SUCCESS) => {
Expand Down Expand Up @@ -828,7 +826,6 @@ impl Session {
Ok((client, self))
}
_ => {
self.common.received_data = false;
info!("Unhandled packet: {:?}", buf);
Ok((client, self))
}
Expand Down
8 changes: 8 additions & 0 deletions russh/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,14 @@ impl Session {
}
}

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

0 comments on commit 1541fe5

Please sign in to comment.