mirror of
https://codeberg.org/spire/dispenser.git
synced 2026-06-03 18:14:06 +02:00
fix ssh timeout
This commit is contained in:
parent
baca3b61ba
commit
3f26d17187
1 changed files with 4 additions and 1 deletions
|
|
@ -25,6 +25,8 @@ pub enum SshError {
|
|||
ConnectionTimeout,
|
||||
#[error("Disconnected by server")]
|
||||
Disconnected,
|
||||
#[error("Connection refused")]
|
||||
Refused,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
@ -37,6 +39,7 @@ impl From<thrussh::Error> for SshError {
|
|||
Error::Disconnect | Error::HUP => SshError::Disconnected,
|
||||
Error::ConnectionTimeout => SshError::ConnectionTimeout,
|
||||
Error::IO(io) if io.raw_os_error() == Some(110) => SshError::ConnectionTimeout,
|
||||
Error::IO(io) if io.raw_os_error() == Some(111) => SshError::Refused,
|
||||
e => SshError::Other(SshErrorImpl(e)),
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +82,7 @@ impl SshSession {
|
|||
sleep(Duration::from_secs(1)).await;
|
||||
match SshSession::open_impl(ip, auth).await {
|
||||
Ok(ssh) => return Ok(ssh),
|
||||
Err(SshError::ConnectionTimeout) => {}
|
||||
Err(SshError::ConnectionTimeout | SshError::Refused) => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue