mirror of
https://codeberg.org/spire/dispenser.git
synced 2026-06-03 18:14:06 +02:00
clippy
This commit is contained in:
parent
099ec46830
commit
27757a48e4
2 changed files with 9 additions and 11 deletions
|
|
@ -67,11 +67,8 @@ impl DynDnsClient {
|
|||
match text.as_str() {
|
||||
"badauth" => Err(DynDnsError::Unauthorized),
|
||||
"!yours" => Err(DynDnsError::NotYourDomain),
|
||||
"nochg" => Ok(()),
|
||||
"good" => Ok(()),
|
||||
"notfqdn" => Err(DynDnsError::InvalidHostname),
|
||||
"nohost" => Err(DynDnsError::InvalidHostname),
|
||||
"numhost" => Err(DynDnsError::InvalidHostname),
|
||||
"nochg" | "good" => Ok(()),
|
||||
"notfqdn" | "nohost" | "numhost" => Err(DynDnsError::InvalidHostname),
|
||||
_ => Err(DynDnsError::InvalidResponse(text)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
src/ssh.rs
13
src/ssh.rs
|
|
@ -1,4 +1,5 @@
|
|||
use futures_util::future::{self};
|
||||
use std::convert::identity;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::io::Write;
|
||||
use std::net::IpAddr;
|
||||
|
|
@ -32,10 +33,9 @@ pub struct SshErrorImpl(thrussh::Error);
|
|||
impl From<thrussh::Error> for SshError {
|
||||
fn from(e: thrussh::Error) -> Self {
|
||||
match e {
|
||||
thrussh::Error::Disconnect => SshError::Disconnected,
|
||||
thrussh::Error::HUP => SshError::Disconnected,
|
||||
thrussh::Error::ConnectionTimeout => SshError::ConnectionTimeout,
|
||||
thrussh::Error::IO(io) if io.raw_os_error() == Some(110) => SshError::ConnectionTimeout,
|
||||
Error::Disconnect | Error::HUP => SshError::Disconnected,
|
||||
Error::ConnectionTimeout => SshError::ConnectionTimeout,
|
||||
Error::IO(io) if io.raw_os_error() == Some(110) => SshError::ConnectionTimeout,
|
||||
e => SshError::Other(SshErrorImpl(e)),
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ impl Debug for SshSession {
|
|||
impl SshSession {
|
||||
#[instrument(skip(password))]
|
||||
pub async fn open(ip: IpAddr, password: &str) -> Result<Self, SshError> {
|
||||
Ok(timeout(Duration::from_secs(5 * 60), async move {
|
||||
timeout(Duration::from_secs(5 * 60), async move {
|
||||
loop {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
match SshSession::open_impl(ip, password).await {
|
||||
|
|
@ -84,7 +84,8 @@ impl SshSession {
|
|||
}
|
||||
})
|
||||
.await
|
||||
.map_err(|_| SshError::ConnectionTimeout)??)
|
||||
.map_err(|_| SshError::ConnectionTimeout)
|
||||
.and_then(identity)
|
||||
}
|
||||
|
||||
async fn open_impl(ip: IpAddr, password: &str) -> Result<Self, SshError> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue