mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
clippy all codes (#1214)
1. clippy code 2. add fmt and clippy check in ci
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user