Skip to content

Commit 45edb29

Browse files
committed
added specific error types for keepalive and inactivity timeouts
1 parent 5c60d30 commit 45edb29

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

russh/src/client/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,15 +818,15 @@ impl Session {
818818
() = &mut keepalive_timer => {
819819
if self.common.config.keepalive_max != 0 && self.common.alive_timeouts > self.common.config.keepalive_max {
820820
debug!("Timeout, server not responding to keepalives");
821-
break
821+
return Err(crate::Error::KeepaliveTimeout);
822822
}
823823
self.common.alive_timeouts = self.common.alive_timeouts.saturating_add(1);
824824
self.send_keepalive(true);
825825
sent_keepalive = true;
826826
}
827827
() = &mut inactivity_timer => {
828828
debug!("timeout");
829-
break
829+
return Err(crate::Error::InactivityTimeout);
830830
}
831831
msg = self.receiver.recv(), if !self.is_rekeying() => {
832832
match msg {

russh/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ pub enum Error {
249249
#[error("Connection timeout")]
250250
ConnectionTimeout,
251251

252+
/// Keepalive timeout.
253+
#[error("Keepalive timeout")]
254+
KeepaliveTimeout,
255+
256+
/// Inactivity timeout.
257+
#[error("Inactivity timeout")]
258+
InactivityTimeout,
259+
252260
/// Missing authentication method.
253261
#[error("No authentication method")]
254262
NoAuthMethod,

russh/src/server/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,15 +447,15 @@ impl Session {
447447
() = &mut keepalive_timer => {
448448
if self.common.config.keepalive_max != 0 && self.common.alive_timeouts > self.common.config.keepalive_max {
449449
debug!("Timeout, client not responding to keepalives");
450-
break
450+
return Err(crate::Error::KeepaliveTimeout);
451451
}
452452
self.common.alive_timeouts = self.common.alive_timeouts.saturating_add(1);
453453
sent_keepalive = true;
454454
self.keepalive_request();
455455
}
456456
() = &mut inactivity_timer => {
457457
debug!("timeout");
458-
break
458+
return Err(crate::Error::InactivityTimeout);
459459
}
460460
msg = self.receiver.recv(), if !self.is_rekeying() => {
461461
match msg {

0 commit comments

Comments
 (0)