Allows for erroneous Clippy lints

Signed-off-by: Mathias Hall-Andersen <mathias@hall-andersen.dk>
This commit is contained in:
Mathias Hall-Andersen
2021-01-13 18:10:04 +01:00
parent 1fb7975d3d
commit 7d84ef9064
10 changed files with 30 additions and 14 deletions

View File

@@ -318,6 +318,7 @@ impl Tun for LinuxTun {
impl PlatformTun for LinuxTun {
type Status = LinuxTunStatus;
#[allow(clippy::type_complexity)]
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error> {
// construct request struct
let mut req = Ifreq {

View File

@@ -666,6 +666,8 @@ impl LinuxUDP {
impl PlatformUDP for LinuxUDP {
type Owner = LinuxOwner;
#[allow(clippy::type_complexity)]
#[allow(clippy::unnecessary_unwrap)]
fn bind(mut port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error> {
log::debug!("bind to port {}", port);

View File

@@ -58,5 +58,6 @@ pub trait Tun: Send + Sync + 'static {
pub trait PlatformTun: Tun {
type Status: Status;
#[allow(clippy::type_complexity)]
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error>;
}

View File

@@ -41,5 +41,6 @@ pub trait PlatformUDP: UDP {
/// Bind to a new port, returning the reader/writer and
/// an associated instance of the owner type, which closes the UDP socket upon "drop"
/// and enables configuration of the fwmark value.
#[allow(clippy::type_complexity)]
fn bind(port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error>;
}

View File

@@ -141,6 +141,7 @@ impl Generator {
pub fn process(&mut self, reply: &CookieReply) -> Result<(), HandshakeError> {
let mac1 = self.last_mac1.ok_or(HandshakeError::InvalidState)?;
let mut tau = [0u8; SIZE_COOKIE];
#[allow(clippy::unnecessary_mut_passed)]
XOPEN!(
&self.cookie_key, // key
&reply.f_nonce, // nonce

View File

@@ -37,6 +37,7 @@ impl Drop for RateLimiter {
impl RateLimiter {
pub fn new() -> Self {
#[allow(clippy::mutex_atomic)]
RateLimiter(Arc::new(RateLimiterInner {
gc_dropped: (Mutex::new(false), Condvar::new()),
gc_running: AtomicBool::from(false),
@@ -143,7 +144,7 @@ mod tests {
expected.push(Result {
allowed: true,
wait: Duration::new(0, 0),
text: "inital burst",
text: "initial burst",
});
}

View File

@@ -1,12 +1,11 @@
/* The wireguard sub-module represents a full, pure, WireGuard implementation:
*
* The WireGuard device described here does not depend on particular IO implementations
* or UAPI, and can be instantiated in unit-tests with the dummy IO implementation.
*
* The code at this level serves to "glue" the handshake state-machine
* and the crypto-key router code together,
* e.g. every WireGuard peer consists of a handshake and router peer.
*/
/// The wireguard sub-module represents a full, pure, WireGuard implementation:
///
/// The WireGuard device described here does not depend on particular IO implementations
/// or UAPI, and can be instantiated in unit-tests with the dummy IO implementation.
///
/// The code at this level serves to "glue" the handshake state-machine
/// and the crypto-key router code together,
/// e.g. every WireGuard peer consists of one handshake peer and one router peer.
mod constants;
mod handshake;
mod peer;
@@ -14,12 +13,14 @@ mod queue;
mod router;
mod timers;
mod types;
mod wireguard;
mod workers;
#[cfg(test)]
mod tests;
#[allow(clippy::module_inception)]
mod wireguard;
// represents a WireGuard interface
pub use wireguard::WireGuard;

View File

@@ -30,6 +30,7 @@ pub struct DeviceInner<E: Endpoint, C: Callbacks, T: tun::Writer, B: udp::Writer
pub(super) outbound: RwLock<(bool, Option<B>)>,
// routing
#[allow(clippy::type_complexity)]
pub(super) recv: RwLock<HashMap<u32, Arc<DecryptionState<E, C, T, B>>>>, /* receiver id -> decryption state */
pub(super) table: RoutingTable<Peer<E, C, T, B>>,

View File

@@ -25,6 +25,7 @@ struct TransmissionCounter {
}
impl TransmissionCounter {
#[allow(dead_code)]
fn new() -> TransmissionCounter {
TransmissionCounter {
sent: AtomicUsize::new(0),
@@ -32,15 +33,18 @@ impl TransmissionCounter {
}
}
#[allow(dead_code)]
fn reset(&self) {
self.sent.store(0, Ordering::SeqCst);
self.recv.store(0, Ordering::SeqCst);
}
#[allow(dead_code)]
fn sent(&self) -> usize {
self.sent.load(Ordering::Acquire)
}
#[allow(dead_code)]
fn recv(&self) -> usize {
self.recv.load(Ordering::Acquire)
}

View File

@@ -13,19 +13,20 @@ use super::udp::UDP;
use super::workers::{handshake_worker, tun_worker, udp_worker};
use std::fmt;
use std::thread;
use std::ops::Deref;
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::sync::Arc;
use std::sync::Condvar;
use std::sync::Mutex as StdMutex;
use std::thread;
use std::time::Instant;
use hjul::Runner;
use rand::rngs::OsRng;
use rand::Rng;
use spin::{Mutex, RwLock};
use hjul::Runner;
use spin::{Mutex, RwLock};
use x25519_dalek::{PublicKey, StaticSecret};
pub struct WireguardInner<T: Tun, B: UDP> {
@@ -45,6 +46,7 @@ pub struct WireguardInner<T: Tun, B: UDP> {
pub mtu: AtomicUsize,
// peer map
#[allow(clippy::type_complexity)]
pub peers: RwLock<
handshake::Device<router::PeerHandle<B::Endpoint, PeerInner<T, B>, T::Writer, B::Writer>>,
>,
@@ -85,6 +87,7 @@ impl<T: Tun, B: UDP> Clone for WireGuard<T, B> {
}
}
#[allow(clippy::mutex_atomic)]
impl WaitCounter {
pub fn wait(&self) {
let mut nread = self.0.lock().unwrap();