fix clippy complaints
This commit is contained in:
parent
93cb25cd54
commit
4023b5bad4
10
src/auth.rs
10
src/auth.rs
@ -13,10 +13,12 @@ pub async fn dyn_ip_update(
|
||||
) -> anyhow::Result<std::net::Ipv4Addr> {
|
||||
debug!(%number, %port, "starting dyn ip update");
|
||||
|
||||
let mut packet = Packet::default();
|
||||
packet.header = Header {
|
||||
kind: PacketKind::DynIpUpdate.raw(),
|
||||
length: 8,
|
||||
let mut packet = Packet {
|
||||
header: Header {
|
||||
kind: PacketKind::DynIpUpdate.raw(),
|
||||
length: 8,
|
||||
},
|
||||
data: Vec::new(),
|
||||
};
|
||||
|
||||
packet.data.clear();
|
||||
|
@ -249,7 +249,7 @@ pub async fn connection_handler(
|
||||
packet,
|
||||
)?;
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
PacketKind::RemAck => {
|
||||
@ -313,7 +313,7 @@ pub async fn connection_handler(
|
||||
.await?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
kind => bail!("unexpected packet: {:?}", kind),
|
||||
|
@ -4,7 +4,7 @@ pub const AUTH_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
pub const CALL_ACK_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
pub const CALL_TIMEOUT: Duration = Duration::from_secs(24 * 60 * 60);
|
||||
pub const PORT_RETRY_TIME: Duration = Duration::from_secs(15 * 60);
|
||||
pub const PORT_OWNERSHIP_TIMEOUT: Duration = Duration::from_secs(1 * 60 * 60);
|
||||
pub const PORT_OWNERSHIP_TIMEOUT: Duration = Duration::from_secs(60 * 60);
|
||||
pub const PING_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
pub const SEND_PING_INTERVAL: Duration = Duration::from_secs(20);
|
||||
|
||||
|
16
src/main.rs
16
src/main.rs
@ -63,7 +63,7 @@ fn parse_log_level<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Level,
|
||||
|
||||
String::deserialize(deserializer)?
|
||||
.parse()
|
||||
.map_err(|err| D::Error::custom(err))
|
||||
.map_err(D::Error::custom)
|
||||
}
|
||||
|
||||
fn parse_time_format<'de, D: Deserializer<'de>>(
|
||||
@ -72,7 +72,7 @@ fn parse_time_format<'de, D: Deserializer<'de>>(
|
||||
use serde::de::Error;
|
||||
|
||||
time::format_description::parse_owned::<2>(&String::deserialize(deserializer)?)
|
||||
.map_err(|err| D::Error::custom(err))
|
||||
.map_err(D::Error::custom)
|
||||
}
|
||||
|
||||
fn maybe_parse_socket_addr<'de, D: Deserializer<'de>>(
|
||||
@ -82,12 +82,10 @@ fn maybe_parse_socket_addr<'de, D: Deserializer<'de>>(
|
||||
|
||||
Option::<String>::deserialize(deserializer)?
|
||||
.map(|s| {
|
||||
Ok::<_, D::Error>(
|
||||
s.to_socket_addrs()
|
||||
.map_err(|err| D::Error::custom(err))?
|
||||
.next()
|
||||
.ok_or_else(|| D::Error::invalid_length(0, &"one or more"))?,
|
||||
)
|
||||
s.to_socket_addrs()
|
||||
.map_err(D::Error::custom)?
|
||||
.next()
|
||||
.ok_or_else(|| D::Error::invalid_length(0, &"one or more"))
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
@ -97,7 +95,7 @@ fn parse_socket_addr<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Socke
|
||||
|
||||
let addr = String::deserialize(deserializer)?
|
||||
.to_socket_addrs()
|
||||
.map_err(|err| D::Error::custom(err))?
|
||||
.map_err(D::Error::custom)?
|
||||
.next()
|
||||
.ok_or_else(|| D::Error::invalid_length(0, &"one or more"))?;
|
||||
|
||||
|
12
src/ports.rs
12
src/ports.rs
@ -67,7 +67,7 @@ fn duration_in_hours(duration: Duration) -> String {
|
||||
fn format_instant(instant: Instant) -> String {
|
||||
let when = duration_in_hours(instant.elapsed()) + " ago";
|
||||
|
||||
let when = (|| -> anyhow::Result<_> {
|
||||
(|| -> anyhow::Result<_> {
|
||||
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH)? - instant.elapsed();
|
||||
let date = time::OffsetDateTime::from_unix_timestamp(timestamp.as_secs() as i64)?
|
||||
.to_offset(*TIME_ZONE_OFFSET.get().unwrap())
|
||||
@ -75,9 +75,7 @@ fn format_instant(instant: Instant) -> String {
|
||||
|
||||
Ok(format!("{date} ({when})"))
|
||||
})()
|
||||
.unwrap_or(when);
|
||||
|
||||
when
|
||||
.unwrap_or(when)
|
||||
}
|
||||
|
||||
fn instant_from_timestamp(timestamp: UnixTimestamp) -> Instant {
|
||||
@ -292,14 +290,12 @@ impl PortHandler {
|
||||
let is_allocted = self
|
||||
.allocated_ports
|
||||
.iter()
|
||||
.find(|(_, allocated_port)| *allocated_port == port)
|
||||
.is_some();
|
||||
.any(|(_, allocated_port)| allocated_port == port);
|
||||
|
||||
let is_errored = self
|
||||
.errored_ports
|
||||
.iter()
|
||||
.find(|(_, errored_port)| errored_port == port)
|
||||
.is_some();
|
||||
.any(|(_, errored_port)| errored_port == port);
|
||||
|
||||
!(is_allocted || is_errored)
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user