make clippy happy (kinda)
This commit is contained in:
parent
45011d498a
commit
b2dbff3611
@ -243,7 +243,7 @@ impl Server {
|
||||
if frag != 0 {
|
||||
Err(IoError::new(
|
||||
ErrorKind::Other,
|
||||
format!("fragmented packet is not supported"),
|
||||
"fragmented packet is not supported",
|
||||
))?;
|
||||
}
|
||||
|
||||
@ -282,8 +282,12 @@ impl Server {
|
||||
}
|
||||
|
||||
pub async fn recv_pkt(pkt: Bytes, addr: Address, assoc_id: u16) -> Result<(), Error> {
|
||||
let sessions = SERVER.get().unwrap().udp_sessions.lock();
|
||||
let Some(assoc_socket) = sessions.get(&assoc_id) else { unreachable!() };
|
||||
let assoc_socket = {
|
||||
let sessions = SERVER.get().unwrap().udp_sessions.lock();
|
||||
let Some(assoc_socket) = sessions.get(&assoc_id) else { unreachable!() };
|
||||
assoc_socket.clone()
|
||||
};
|
||||
|
||||
assoc_socket.send(pkt, 0, addr).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ impl Connect {
|
||||
match &self.model {
|
||||
Side::Client(model) => {
|
||||
let Header::Connect(conn) = model.header() else { unreachable!() };
|
||||
&conn.addr()
|
||||
conn.addr()
|
||||
}
|
||||
Side::Server(model) => model.addr(),
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ impl Server {
|
||||
loop {
|
||||
let conn = self.ep.accept().await.unwrap();
|
||||
|
||||
tokio::spawn(Connection::new(
|
||||
tokio::spawn(Connection::handle(
|
||||
conn,
|
||||
self.token.clone(),
|
||||
self.udp_relay_ipv6,
|
||||
@ -161,8 +161,9 @@ struct Connection {
|
||||
max_concurrent_bi_streams: Arc<AtomicUsize>,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
impl Connection {
|
||||
async fn new(
|
||||
async fn handle(
|
||||
conn: Connecting,
|
||||
token: Arc<[u8]>,
|
||||
udp_relay_ipv6: bool,
|
||||
@ -310,7 +311,6 @@ impl Connection {
|
||||
Err(err) => {
|
||||
eprintln!("{err}");
|
||||
self.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -350,7 +350,6 @@ impl Connection {
|
||||
Err(err) => {
|
||||
eprintln!("{err}");
|
||||
self.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,7 +385,6 @@ impl Connection {
|
||||
Err(err) => {
|
||||
eprintln!("{err}");
|
||||
self.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ impl<B> Connection<B>
|
||||
where
|
||||
B: AsRef<[u8]>,
|
||||
{
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
let task_associate_count = Counter::new();
|
||||
|
||||
@ -174,6 +175,7 @@ where
|
||||
.send_packet(assoc_id, addr, max_pkt_size)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn recv_packet(
|
||||
&mut self,
|
||||
sessions: Arc<Mutex<Self>>,
|
||||
@ -189,6 +191,7 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn recv_packet_unrestricted(
|
||||
&mut self,
|
||||
sessions: Arc<Mutex<Self>>,
|
||||
@ -215,6 +218,7 @@ where
|
||||
Dissociate::<side::Rx>::new(assoc_id)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn insert(
|
||||
&mut self,
|
||||
assoc_id: u16,
|
||||
@ -270,6 +274,7 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn recv_packet(
|
||||
&self,
|
||||
sessions: Arc<Mutex<UdpSessions<B>>>,
|
||||
@ -283,6 +288,7 @@ where
|
||||
Packet::<side::Rx, B>::new(sessions, assoc_id, pkt_id, frag_total, frag_id, size, addr)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn insert(
|
||||
&mut self,
|
||||
assoc_id: u16,
|
||||
|
@ -23,6 +23,7 @@ impl Authenticate {
|
||||
Self::TYPE_CODE
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
32
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ impl Connect {
|
||||
Self::TYPE_CODE
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
self.addr.len()
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ impl Dissociate {
|
||||
Self::TYPE_CODE
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
2
|
||||
}
|
||||
|
@ -17,13 +17,12 @@ impl Heartbeat {
|
||||
Self::TYPE_CODE
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Heartbeat> for () {
|
||||
fn from(_: Heartbeat) -> Self {
|
||||
()
|
||||
}
|
||||
fn from(_: Heartbeat) -> Self {}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ impl Header {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
2 + match self {
|
||||
Self::Authenticate(auth) => auth.len(),
|
||||
@ -106,12 +107,13 @@ impl Address {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
1 + match self {
|
||||
Address::None => 0,
|
||||
Address::DomainAddress(addr, _) => 1 + addr.len() + 2,
|
||||
Address::SocketAddress(addr) => match addr {
|
||||
SocketAddr::V4(_) => 1 * 4 + 2,
|
||||
SocketAddr::V4(_) => 4 + 2,
|
||||
SocketAddr::V6(_) => 2 * 8 + 2,
|
||||
},
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ impl Packet {
|
||||
Self::TYPE_CODE
|
||||
}
|
||||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self) -> usize {
|
||||
Self::len_without_addr() + self.addr.len()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user