From 19be8430a3f92366067e2323d8ce57bb05d27890 Mon Sep 17 00:00:00 2001 From: dev0 Date: Wed, 16 Oct 2024 23:15:54 +1100 Subject: [PATCH] clippy --- clash_lib/src/proxy/hysteria2/codec.rs | 2 +- clash_lib/src/proxy/hysteria2/congestion.rs | 1 + clash_lib/src/proxy/hysteria2/mod.rs | 12 ++++++------ clash_lib/src/proxy/hysteria2/salamander.rs | 2 ++ clash_lib/src/proxy/hysteria2/udp_hop.rs | 10 +++++----- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/clash_lib/src/proxy/hysteria2/codec.rs b/clash_lib/src/proxy/hysteria2/codec.rs index a5f35985e..2e50e8ec1 100644 --- a/clash_lib/src/proxy/hysteria2/codec.rs +++ b/clash_lib/src/proxy/hysteria2/codec.rs @@ -123,5 +123,5 @@ fn hy2_resp_parse() { let mut src = BytesMut::from(&[0x01, 0x00, 0x00][..]); let msg = Hy2TcpCodec.decode(&mut src).unwrap().unwrap(); assert!(msg.status == 0x1); - assert!(msg.msg == ""); + assert!(msg.msg.is_empty()); } diff --git a/clash_lib/src/proxy/hysteria2/congestion.rs b/clash_lib/src/proxy/hysteria2/congestion.rs index 4565358b9..6c6d1dc57 100644 --- a/clash_lib/src/proxy/hysteria2/congestion.rs +++ b/clash_lib/src/proxy/hysteria2/congestion.rs @@ -42,6 +42,7 @@ pub struct Burtal { budget_at_last_sent: u64, rtt: u64, in_flight: u64, + #[allow(dead_code)] send_now: Instant, sess: quinn::Connection, diff --git a/clash_lib/src/proxy/hysteria2/mod.rs b/clash_lib/src/proxy/hysteria2/mod.rs index d84dfb02c..0cdb0d347 100644 --- a/clash_lib/src/proxy/hysteria2/mod.rs +++ b/clash_lib/src/proxy/hysteria2/mod.rs @@ -70,10 +70,13 @@ pub struct HystOption { pub salamander: Option, pub skip_cert_verify: bool, pub alpn: Vec, + #[allow(dead_code)] pub up_down: Option<(u64, u64)>, pub fingerprint: Option, pub ca: Option, + #[allow(dead_code)] pub ca_str: Option, + #[allow(dead_code)] pub cwnd: Option, } @@ -157,7 +160,7 @@ impl ServerCertVerifier for CertVerifyOption { enum CcRx { Auto, - Fixed(u64), + Fixed(#[allow(dead_code)] u64), } impl FromStr for CcRx { @@ -309,10 +312,7 @@ impl Handler { ep.set_default_client_config(self.client_config.clone()); let session = ep - .connect( - server_socket_addr, - self.opts.sni.as_ref().map(|s| s.as_str()).unwrap_or(""), - )? + .connect(server_socket_addr, self.opts.sni.as_deref().unwrap_or(""))? .await?; let (h3_conn, _rx, udp) = Self::auth(&session, &self.opts.passwd).await?; *self.support_udp.write().unwrap() = udp; @@ -426,7 +426,7 @@ impl OutboundHandler for Handler { Some(s) => s.clone(), None => { let (session, h3_conn) = self - .new_authed_session(&sess, resolver) + .new_authed_session(sess, resolver) .await .map_err(|e| { std::io::Error::new( diff --git a/clash_lib/src/proxy/hysteria2/salamander.rs b/clash_lib/src/proxy/hysteria2/salamander.rs index 29c633d44..b69a0c025 100644 --- a/clash_lib/src/proxy/hysteria2/salamander.rs +++ b/clash_lib/src/proxy/hysteria2/salamander.rs @@ -26,6 +26,7 @@ impl SalamanderObfs { /// /// new() should init a blake2b256 hasher with key to reduce calculation, /// but rust-analyzer can't recognize its type + #[allow(dead_code)] pub fn new(key: Vec) -> Self { Self { key } } @@ -67,6 +68,7 @@ pub struct Salamander { } impl Salamander { + #[allow(dead_code)] pub fn new(socket: std::net::UdpSocket, key: Vec) -> std::io::Result { use quinn::Runtime; let inner = TokioRuntime.wrap_udp_socket(socket)?; diff --git a/clash_lib/src/proxy/hysteria2/udp_hop.rs b/clash_lib/src/proxy/hysteria2/udp_hop.rs index f5566ab5d..b154367b4 100644 --- a/clash_lib/src/proxy/hysteria2/udp_hop.rs +++ b/clash_lib/src/proxy/hysteria2/udp_hop.rs @@ -213,9 +213,9 @@ impl AsyncUdpSocket for UdpHop { match io.poll_recv(cx, bufs, &mut meta[len..]) { Poll::Pending => { if len > 0 { - return Poll::Ready(Ok(len)); + Poll::Ready(Ok(len)) } else { - return Poll::Pending; + Poll::Pending } } Poll::Ready(Ok(res)) => { @@ -223,13 +223,13 @@ impl AsyncUdpSocket for UdpHop { .skip(len) .take(res) .for_each(|m| m.addr.set_port(self.init_port)); - return Poll::Ready(Ok(len + res)); + Poll::Ready(Ok(len + res)) } Poll::Ready(Err(e)) => { tracing::trace!("poll cur conn err {}", e); - return Poll::Ready(Err(e)); + Poll::Ready(Err(e)) } - }; + } } fn local_addr(&self) -> io::Result {