Skip to content

Commit

Permalink
Allows for erroneous Clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias Hall-Andersen <[email protected]>
  • Loading branch information
rot256 committed Jan 13, 2021
1 parent 1fb7975 commit 7d84ef9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/platform/linux/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/platform/linux/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/platform/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
1 change: 1 addition & 0 deletions src/platform/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
1 change: 1 addition & 0 deletions src/wireguard/handshake/macs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/wireguard/handshake/ratelimiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -143,7 +144,7 @@ mod tests {
expected.push(Result {
allowed: true,
wait: Duration::new(0, 0),
text: "inital burst",
text: "initial burst",
});
}

Expand Down
21 changes: 11 additions & 10 deletions src/wireguard/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/* 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;
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;

Expand Down
1 change: 1 addition & 0 deletions src/wireguard/router/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,

Expand Down
4 changes: 4 additions & 0 deletions src/wireguard/router/tests/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ struct TransmissionCounter {
}

impl TransmissionCounter {
#[allow(dead_code)]
fn new() -> TransmissionCounter {
TransmissionCounter {
sent: AtomicUsize::new(0),
recv: AtomicUsize::new(0),
}
}

#[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)
}
Expand Down
9 changes: 6 additions & 3 deletions src/wireguard/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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>>,
>,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7d84ef9

Please sign in to comment.