Allows for erroneous Clippy lints
Signed-off-by: Mathias Hall-Andersen <mathias@hall-andersen.dk>
This commit is contained in:
@@ -318,6 +318,7 @@ impl Tun for LinuxTun {
|
|||||||
impl PlatformTun for LinuxTun {
|
impl PlatformTun for LinuxTun {
|
||||||
type Status = LinuxTunStatus;
|
type Status = LinuxTunStatus;
|
||||||
|
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error> {
|
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error> {
|
||||||
// construct request struct
|
// construct request struct
|
||||||
let mut req = Ifreq {
|
let mut req = Ifreq {
|
||||||
|
|||||||
@@ -666,6 +666,8 @@ impl LinuxUDP {
|
|||||||
impl PlatformUDP for LinuxUDP {
|
impl PlatformUDP for LinuxUDP {
|
||||||
type Owner = LinuxOwner;
|
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> {
|
fn bind(mut port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error> {
|
||||||
log::debug!("bind to port {}", port);
|
log::debug!("bind to port {}", port);
|
||||||
|
|
||||||
|
|||||||
@@ -58,5 +58,6 @@ pub trait Tun: Send + Sync + 'static {
|
|||||||
pub trait PlatformTun: Tun {
|
pub trait PlatformTun: Tun {
|
||||||
type Status: Status;
|
type Status: Status;
|
||||||
|
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error>;
|
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,5 +41,6 @@ pub trait PlatformUDP: UDP {
|
|||||||
/// Bind to a new port, returning the reader/writer and
|
/// Bind to a new port, returning the reader/writer and
|
||||||
/// an associated instance of the owner type, which closes the UDP socket upon "drop"
|
/// an associated instance of the owner type, which closes the UDP socket upon "drop"
|
||||||
/// and enables configuration of the fwmark value.
|
/// 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>;
|
fn bind(port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ impl Generator {
|
|||||||
pub fn process(&mut self, reply: &CookieReply) -> Result<(), HandshakeError> {
|
pub fn process(&mut self, reply: &CookieReply) -> Result<(), HandshakeError> {
|
||||||
let mac1 = self.last_mac1.ok_or(HandshakeError::InvalidState)?;
|
let mac1 = self.last_mac1.ok_or(HandshakeError::InvalidState)?;
|
||||||
let mut tau = [0u8; SIZE_COOKIE];
|
let mut tau = [0u8; SIZE_COOKIE];
|
||||||
|
#[allow(clippy::unnecessary_mut_passed)]
|
||||||
XOPEN!(
|
XOPEN!(
|
||||||
&self.cookie_key, // key
|
&self.cookie_key, // key
|
||||||
&reply.f_nonce, // nonce
|
&reply.f_nonce, // nonce
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ impl Drop for RateLimiter {
|
|||||||
|
|
||||||
impl RateLimiter {
|
impl RateLimiter {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
#[allow(clippy::mutex_atomic)]
|
||||||
RateLimiter(Arc::new(RateLimiterInner {
|
RateLimiter(Arc::new(RateLimiterInner {
|
||||||
gc_dropped: (Mutex::new(false), Condvar::new()),
|
gc_dropped: (Mutex::new(false), Condvar::new()),
|
||||||
gc_running: AtomicBool::from(false),
|
gc_running: AtomicBool::from(false),
|
||||||
@@ -143,7 +144,7 @@ mod tests {
|
|||||||
expected.push(Result {
|
expected.push(Result {
|
||||||
allowed: true,
|
allowed: true,
|
||||||
wait: Duration::new(0, 0),
|
wait: Duration::new(0, 0),
|
||||||
text: "inital burst",
|
text: "initial burst",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
/* The wireguard sub-module represents a full, pure, WireGuard implementation:
|
/// The wireguard sub-module represents a full, pure, WireGuard implementation:
|
||||||
*
|
///
|
||||||
* The WireGuard device described here does not depend on particular IO implementations
|
/// 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.
|
/// 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
|
/// The code at this level serves to "glue" the handshake state-machine
|
||||||
* and the crypto-key router code together,
|
/// and the crypto-key router code together,
|
||||||
* e.g. every WireGuard peer consists of a handshake and router peer.
|
/// e.g. every WireGuard peer consists of one handshake peer and one router peer.
|
||||||
*/
|
|
||||||
mod constants;
|
mod constants;
|
||||||
mod handshake;
|
mod handshake;
|
||||||
mod peer;
|
mod peer;
|
||||||
@@ -14,12 +13,14 @@ mod queue;
|
|||||||
mod router;
|
mod router;
|
||||||
mod timers;
|
mod timers;
|
||||||
mod types;
|
mod types;
|
||||||
mod wireguard;
|
|
||||||
mod workers;
|
mod workers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
#[allow(clippy::module_inception)]
|
||||||
|
mod wireguard;
|
||||||
|
|
||||||
// represents a WireGuard interface
|
// represents a WireGuard interface
|
||||||
pub use wireguard::WireGuard;
|
pub use wireguard::WireGuard;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ pub struct DeviceInner<E: Endpoint, C: Callbacks, T: tun::Writer, B: udp::Writer
|
|||||||
pub(super) outbound: RwLock<(bool, Option<B>)>,
|
pub(super) outbound: RwLock<(bool, Option<B>)>,
|
||||||
|
|
||||||
// routing
|
// routing
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
pub(super) recv: RwLock<HashMap<u32, Arc<DecryptionState<E, C, T, B>>>>, /* receiver id -> decryption state */
|
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>>,
|
pub(super) table: RoutingTable<Peer<E, C, T, B>>,
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ struct TransmissionCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TransmissionCounter {
|
impl TransmissionCounter {
|
||||||
|
#[allow(dead_code)]
|
||||||
fn new() -> TransmissionCounter {
|
fn new() -> TransmissionCounter {
|
||||||
TransmissionCounter {
|
TransmissionCounter {
|
||||||
sent: AtomicUsize::new(0),
|
sent: AtomicUsize::new(0),
|
||||||
@@ -32,15 +33,18 @@ impl TransmissionCounter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn reset(&self) {
|
fn reset(&self) {
|
||||||
self.sent.store(0, Ordering::SeqCst);
|
self.sent.store(0, Ordering::SeqCst);
|
||||||
self.recv.store(0, Ordering::SeqCst);
|
self.recv.store(0, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn sent(&self) -> usize {
|
fn sent(&self) -> usize {
|
||||||
self.sent.load(Ordering::Acquire)
|
self.sent.load(Ordering::Acquire)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn recv(&self) -> usize {
|
fn recv(&self) -> usize {
|
||||||
self.recv.load(Ordering::Acquire)
|
self.recv.load(Ordering::Acquire)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,20 @@ use super::udp::UDP;
|
|||||||
use super::workers::{handshake_worker, tun_worker, udp_worker};
|
use super::workers::{handshake_worker, tun_worker, udp_worker};
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::thread;
|
||||||
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Condvar;
|
use std::sync::Condvar;
|
||||||
use std::sync::Mutex as StdMutex;
|
use std::sync::Mutex as StdMutex;
|
||||||
use std::thread;
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use hjul::Runner;
|
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use spin::{Mutex, RwLock};
|
|
||||||
|
|
||||||
|
use hjul::Runner;
|
||||||
|
use spin::{Mutex, RwLock};
|
||||||
use x25519_dalek::{PublicKey, StaticSecret};
|
use x25519_dalek::{PublicKey, StaticSecret};
|
||||||
|
|
||||||
pub struct WireguardInner<T: Tun, B: UDP> {
|
pub struct WireguardInner<T: Tun, B: UDP> {
|
||||||
@@ -45,6 +46,7 @@ pub struct WireguardInner<T: Tun, B: UDP> {
|
|||||||
pub mtu: AtomicUsize,
|
pub mtu: AtomicUsize,
|
||||||
|
|
||||||
// peer map
|
// peer map
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
pub peers: RwLock<
|
pub peers: RwLock<
|
||||||
handshake::Device<router::PeerHandle<B::Endpoint, PeerInner<T, B>, T::Writer, B::Writer>>,
|
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 {
|
impl WaitCounter {
|
||||||
pub fn wait(&self) {
|
pub fn wait(&self) {
|
||||||
let mut nread = self.0.lock().unwrap();
|
let mut nread = self.0.lock().unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user