Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug committed Oct 16, 2024
1 parent 7f3e7a2 commit 19be843
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/hysteria2/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
1 change: 1 addition & 0 deletions clash_lib/src/proxy/hysteria2/congestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions clash_lib/src/proxy/hysteria2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ pub struct HystOption {
pub salamander: Option<String>,
pub skip_cert_verify: bool,
pub alpn: Vec<String>,
#[allow(dead_code)]
pub up_down: Option<(u64, u64)>,
pub fingerprint: Option<String>,
pub ca: Option<PathBuf>,
#[allow(dead_code)]
pub ca_str: Option<String>,
#[allow(dead_code)]
pub cwnd: Option<u64>,
}

Expand Down Expand Up @@ -157,7 +160,7 @@ impl ServerCertVerifier for CertVerifyOption {

enum CcRx {
Auto,
Fixed(u64),
Fixed(#[allow(dead_code)] u64),
}

impl FromStr for CcRx {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions clash_lib/src/proxy/hysteria2/salamander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>) -> Self {
Self { key }
}
Expand Down Expand Up @@ -67,6 +68,7 @@ pub struct Salamander {
}

impl Salamander {
#[allow(dead_code)]
pub fn new(socket: std::net::UdpSocket, key: Vec<u8>) -> std::io::Result<Self> {
use quinn::Runtime;
let inner = TokioRuntime.wrap_udp_socket(socket)?;
Expand Down
10 changes: 5 additions & 5 deletions clash_lib/src/proxy/hysteria2/udp_hop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,23 @@ 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)) => {
meta.iter_mut()
.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<std::net::SocketAddr> {
Expand Down

0 comments on commit 19be843

Please sign in to comment.