clippy all codes (#1214)

1. clippy code
2. add fmt and clippy check in ci
This commit is contained in:
Sijie.Sun
2025-08-10 22:56:41 +08:00
committed by GitHub
parent 0087ac3ffc
commit e43537939a
144 changed files with 1475 additions and 1531 deletions
+8 -8
View File
@@ -65,7 +65,7 @@ impl WgConfig {
let my_secret_key = StaticSecret::from(my_sec);
let my_public_key = PublicKey::from(&my_secret_key);
let peer_secret_key = StaticSecret::from(my_sec);
let peer_public_key = my_public_key.clone();
let peer_public_key = my_public_key;
WgConfig {
my_secret_key,
@@ -186,7 +186,7 @@ impl WgPeerData {
recv_buf: &[u8],
) {
let mut send_buf = vec![0u8; MAX_PACKET];
let data = &recv_buf[..];
let data = recv_buf;
let decapsulate_result = {
let mut peer = self.tunn.lock().await;
peer.decapsulate(None, data, &mut send_buf)
@@ -325,9 +325,9 @@ impl WgPeerData {
fn remove_ip_header<'a>(&self, packet: &'a [u8], is_v4: bool) -> &'a [u8] {
if is_v4 {
return &packet[20..];
&packet[20..]
} else {
return &packet[40..];
&packet[40..]
}
}
}
@@ -351,7 +351,7 @@ impl WgPeer {
WgPeer {
tunn: Some(Mutex::new(Tunn::new(
config.my_secret_key.clone(),
config.peer_public_key.clone(),
config.peer_public_key,
None,
None,
rand::thread_rng().next_u32(),
@@ -513,7 +513,7 @@ impl WgTunnelListener {
if !peer_map.contains_key(&addr) {
tracing::info!("New peer: {}", addr);
let mut wg = WgPeer::new(socket.clone(), config.clone(), addr.clone());
let mut wg = WgPeer::new(socket.clone(), config.clone(), addr);
let (stream, sink) = wg.start_and_get_tunnel().split();
let tunnel = Box::new(TunnelWrapper::new(
stream,
@@ -579,7 +579,7 @@ impl TunnelListener for WgTunnelListener {
}
async fn accept(&mut self) -> Result<Box<dyn Tunnel>, super::TunnelError> {
while let Some(tunnel) = self.conn_recv.recv().await {
if let Some(tunnel) = self.conn_recv.recv().await {
tracing::info!(?tunnel, "Accepted tunnel");
return Ok(tunnel);
}
@@ -781,7 +781,7 @@ pub mod tests {
my_secret_key: my_secret_key.clone(),
my_public_key,
peer_secret_key: their_secret_key.clone(),
peer_public_key: their_public_key.clone(),
peer_public_key: their_public_key,
wg_type: WgType::InternalUse,
};