aboutsummaryrefslogtreecommitdiffstats
path: root/src/wireguard
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2021-01-13 18:10:04 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2021-01-13 18:10:52 +0100
commit7d84ef9064559a29b23ab86036f7ef62b450f90c (patch)
tree9a849e0b80218125b007420d7d472665b1619c4e /src/wireguard
parentUpgrade dependencies (diff)
downloadwireguard-rs-7d84ef9064559a29b23ab86036f7ef62b450f90c.tar.xz
wireguard-rs-7d84ef9064559a29b23ab86036f7ef62b450f90c.zip
Allows for erroneous Clippy lintsHEADmaster
Signed-off-by: Mathias Hall-Andersen <mathias@hall-andersen.dk>
Diffstat (limited to 'src/wireguard')
-rw-r--r--src/wireguard/handshake/macs.rs1
-rw-r--r--src/wireguard/handshake/ratelimiter.rs3
-rw-r--r--src/wireguard/mod.rs21
-rw-r--r--src/wireguard/router/device.rs1
-rw-r--r--src/wireguard/router/tests/bench.rs4
-rw-r--r--src/wireguard/wireguard.rs9
6 files changed, 25 insertions, 14 deletions
diff --git a/src/wireguard/handshake/macs.rs b/src/wireguard/handshake/macs.rs
index 8d79c5e..f4f5586 100644
--- a/src/wireguard/handshake/macs.rs
+++ b/src/wireguard/handshake/macs.rs
@@ -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
diff --git a/src/wireguard/handshake/ratelimiter.rs b/src/wireguard/handshake/ratelimiter.rs
index f6210fc..9e796a0 100644
--- a/src/wireguard/handshake/ratelimiter.rs
+++ b/src/wireguard/handshake/ratelimiter.rs
@@ -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",
});
}
diff --git a/src/wireguard/mod.rs b/src/wireguard/mod.rs
index ca17737..e79a250 100644
--- a/src/wireguard/mod.rs
+++ b/src/wireguard/mod.rs
@@ -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;
diff --git a/src/wireguard/router/device.rs b/src/wireguard/router/device.rs
index 54e5149..eeae621 100644
--- a/src/wireguard/router/device.rs
+++ b/src/wireguard/router/device.rs
@@ -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>>,
diff --git a/src/wireguard/router/tests/bench.rs b/src/wireguard/router/tests/bench.rs
index 948a156..c2334b3 100644
--- a/src/wireguard/router/tests/bench.rs
+++ b/src/wireguard/router/tests/bench.rs
@@ -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)
}
diff --git a/src/wireguard/wireguard.rs b/src/wireguard/wireguard.rs
index 35bd342..44d698f 100644
--- a/src/wireguard/wireguard.rs
+++ b/src/wireguard/wireguard.rs
@@ -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();