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