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