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