Skip to content

Commit

Permalink
fixed #141 - renamed Config::connection_timeout to Config::inactivity…
Browse files Browse the repository at this point in the history
…_timeout
  • Loading branch information
Eugeny committed Jun 4, 2023
1 parent af06252 commit 6606e28
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion russh/examples/echoserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn main() {
.init();

let config = russh::server::Config {
connection_timeout: Some(std::time::Duration::from_secs(3600)),
inactivity_timeout: Some(std::time::Duration::from_secs(3600)),
auth_rejection_time: std::time::Duration::from_secs(3),
auth_rejection_time_initial: Some(std::time::Duration::from_secs(0)),
keys: vec![russh_keys::key::KeyPair::generate_ed25519().unwrap()],
Expand Down
2 changes: 1 addition & 1 deletion russh/examples/remote_shell_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Session {
) -> Result<Self> {
let key_pair = load_secret_key(key_path, None)?;
let config = client::Config {
connection_timeout: Some(Duration::from_secs(5)),
inactivity_timeout: Some(Duration::from_secs(5)),
..<_>::default()
};
let config = Arc::new(config);
Expand Down
2 changes: 1 addition & 1 deletion russh/examples/sftp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async fn main() {
auth_rejection_time: Duration::from_secs(3),
auth_rejection_time_initial: Some(Duration::from_secs(0)),
keys: vec![KeyPair::generate_ed25519().unwrap()],
connection_timeout: Some(Duration::from_secs(3600)),
inactivity_timeout: Some(Duration::from_secs(3600)),
..Default::default()
};

Expand Down
4 changes: 2 additions & 2 deletions russh/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ pub struct Config {
/// Lists of preferred algorithms.
pub preferred: negotiation::Preferred,
/// Time after which the connection is garbage-collected.
pub connection_timeout: Option<std::time::Duration>,
pub inactivity_timeout: Option<std::time::Duration>,
/// Whether to expect and wait for an authentication call.
pub anonymous: bool,
}
Expand All @@ -1257,7 +1257,7 @@ impl Default for Config {
window_size: 2097152,
maximum_packet_size: 32768,
preferred: Default::default(),
connection_timeout: None,
inactivity_timeout: None,
anonymous: false,
}
}
Expand Down
6 changes: 3 additions & 3 deletions russh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ mod test_compress {
let client_key = russh_keys::key::KeyPair::generate_ed25519().unwrap();
let mut config = server::Config::default();
config.preferred = Preferred::COMPRESSED;
config.connection_timeout = None; // Some(std::time::Duration::from_secs(3));
config.inactivity_timeout = None; // Some(std::time::Duration::from_secs(3));
config.auth_rejection_time = std::time::Duration::from_secs(3);
config
.keys
Expand Down Expand Up @@ -623,7 +623,7 @@ async fn test_session<RC, RS, CH, SH, F1, F2>(

let client_key = russh_keys::key::KeyPair::generate_ed25519().unwrap();
let mut config = server::Config::default();
config.connection_timeout = None;
config.inactivity_timeout = None;
config.auth_rejection_time = std::time::Duration::from_secs(3);
config
.keys
Expand All @@ -637,7 +637,7 @@ async fn test_session<RC, RS, CH, SH, F1, F2>(

let server_join = tokio::spawn(async move {
let (socket, _) = socket.accept().await.unwrap();

server::run_stream(config, socket, server_handler)
.await
.map_err(|_| ())
Expand Down
8 changes: 4 additions & 4 deletions russh/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//! let client_key = russh_keys::key::KeyPair::generate_ed25519().unwrap();
//! let client_pubkey = Arc::new(client_key.clone_public_key().unwrap());
//! let mut config = russh::server::Config::default();
//! config.connection_timeout = Some(std::time::Duration::from_secs(3));
//! config.inactivity_timeout = Some(std::time::Duration::from_secs(3));
//! config.auth_rejection_time = std::time::Duration::from_secs(3);
//! config.keys.push(russh_keys::key::KeyPair::generate_ed25519().unwrap());
//! let config = Arc::new(config);
Expand Down Expand Up @@ -167,7 +167,7 @@ pub struct Config {
/// Maximal number of allowed authentication attempts.
pub max_auth_attempts: usize,
/// Time after which the connection is garbage-collected.
pub connection_timeout: Option<std::time::Duration>,
pub inactivity_timeout: Option<std::time::Duration>,
}

impl Default for Config {
Expand All @@ -189,7 +189,7 @@ impl Default for Config {
limits: Limits::default(),
preferred: Default::default(),
max_auth_attempts: 10,
connection_timeout: Some(std::time::Duration::from_secs(600)),
inactivity_timeout: Some(std::time::Duration::from_secs(600)),
}
}
}
Expand Down Expand Up @@ -724,7 +724,7 @@ async fn read_ssh_id<R: AsyncRead + Unpin>(
config: Arc<Config>,
read: &mut SshRead<R>,
) -> Result<CommonSession<Arc<Config>>, Error> {
let sshid = if let Some(t) = config.connection_timeout {
let sshid = if let Some(t) = config.inactivity_timeout {
tokio::time::timeout(t, read.read_ssh_id()).await??
} else {
read.read_ssh_id().await?
Expand Down
2 changes: 1 addition & 1 deletion russh/src/server/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl Session {
pin!(reading);
let mut is_reading = None;
let mut decomp = CryptoVec::new();
let delay = self.common.config.connection_timeout;
let delay = self.common.config.inactivity_timeout;

#[allow(clippy::panic)] // false positive in macro
while !self.common.disconnected {
Expand Down

0 comments on commit 6606e28

Please sign in to comment.