diff --git a/client/src/main.rs b/client/src/main.rs index ae04477..4e7201f 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -80,7 +80,7 @@ struct HostsOpt { impl From for Option { fn from(opt: HostsOpt) -> Self { - (!opt.no_write_hosts).then(|| opt.hosts_path) + (!opt.no_write_hosts).then_some(opt.hosts_path) } } @@ -501,7 +501,7 @@ fn up( }; for iface in interfaces { - fetch(&*iface, opts, true, hosts_path.clone(), nat)?; + fetch(&iface, opts, true, hosts_path.clone(), nat)?; } match loop_interval { @@ -725,7 +725,7 @@ fn delete_cidr( let cidr_id = prompts::delete_cidr(&cidrs, &peers, &sub_opts)?; println!("Deleting CIDR..."); - api.http("DELETE", &*format!("/admin/cidrs/{}", cidr_id))?; + api.http("DELETE", &format!("/admin/cidrs/{}", cidr_id))?; println!("CIDR deleted."); @@ -966,7 +966,7 @@ fn override_endpoint( }; let endpoint_contents = if sub_opts.unset { - prompts::unset_override_endpoint(&sub_opts)?.then(|| EndpointContents::Unset) + prompts::unset_override_endpoint(&sub_opts)?.then_some(EndpointContents::Unset) } else { let endpoint = prompts::override_endpoint(&sub_opts, port)?; endpoint.map(EndpointContents::Set) diff --git a/server/src/initialize.rs b/server/src/initialize.rs index f143c20..e6b6b67 100644 --- a/server/src/initialize.rs +++ b/server/src/initialize.rs @@ -26,7 +26,7 @@ fn create_database>( Ok(conn) } -#[derive(Debug, Default, Clone, PartialEq, Parser)] +#[derive(Debug, Default, Clone, PartialEq, Eq, Parser)] pub struct InitializeOpts { /// The network name (ex: evilcorp) #[clap(long)] diff --git a/server/src/main.rs b/server/src/main.rs index fdbdcaa..88c4a3e 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -341,7 +341,7 @@ fn add_peer( (&mut target_file, &target_path), interface, &peer, - &*server_peer, + &server_peer, &cidr_tree, keypair, &SocketAddr::new(config.address, config.listen_port), diff --git a/shared/src/lib.rs b/shared/src/lib.rs index f8c4d1a..3826600 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -93,10 +93,8 @@ pub fn _get_local_addrs() -> Result, io:: interface_addr.address.and_then(|addr| { if let Some(sockaddr_in) = addr.as_sockaddr_in() { Some(IpAddr::V4(Ipv4Addr::from(sockaddr_in.ip()))) - } else if let Some(sockaddr_in6) = addr.as_sockaddr_in6() { - Some(IpAddr::V6(sockaddr_in6.ip())) } else { - None + addr.as_sockaddr_in6().map(|sockaddr_in6| IpAddr::V6(sockaddr_in6.ip())) } }) }); diff --git a/shared/src/types.rs b/shared/src/types.rs index 76c246e..a0012b1 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -22,7 +22,7 @@ use wireguard_control::{ use crate::wg::PeerInfoExt; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Interface { name: InterfaceName, } @@ -55,7 +55,7 @@ impl Display for Interface { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] /// An external endpoint that supports both IP and domain name hosts. pub struct Endpoint { host: Host, @@ -278,12 +278,12 @@ impl<'a> CidrTree<'a> { } } -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] pub struct RedeemContents { pub public_key: String, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct InstallOpts { /// Set a specific interface name #[clap(long, conflicts_with = "default-name")] @@ -298,7 +298,7 @@ pub struct InstallOpts { pub delete_invite: bool, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct AddPeerOpts { /// Name of new peer #[clap(long)] @@ -333,7 +333,7 @@ pub struct AddPeerOpts { pub invite_expires: Option, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct RenamePeerOpts { /// Name of peer to rename #[clap(long)] @@ -348,7 +348,7 @@ pub struct RenamePeerOpts { pub yes: bool, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct AddCidrOpts { /// The CIDR name (eg. 'engineers') #[clap(long)] @@ -367,7 +367,7 @@ pub struct AddCidrOpts { pub yes: bool, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct DeleteCidrOpts { /// The CIDR name (eg. 'engineers') #[clap(long)] @@ -378,7 +378,7 @@ pub struct DeleteCidrOpts { pub yes: bool, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct AddDeleteAssociationOpts { /// The first cidr to associate pub cidr1: Option, @@ -391,7 +391,7 @@ pub struct AddDeleteAssociationOpts { pub yes: bool, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct ListenPortOpts { /// The listen port you'd like to set for the interface #[clap(short, long)] @@ -406,7 +406,7 @@ pub struct ListenPortOpts { pub yes: bool, } -#[derive(Debug, Clone, PartialEq, Args)] +#[derive(Debug, Clone, PartialEq, Eq, Args)] pub struct OverrideEndpointOpts { /// The listen port you'd like to set for the interface #[clap(short, long)] @@ -475,7 +475,7 @@ pub struct NetworkOpts { pub mtu: Option, } -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] pub struct PeerContents { pub name: Hostname, pub ip: IpAddr, @@ -491,7 +491,7 @@ pub struct PeerContents { pub candidates: Vec, } -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] pub struct Peer { pub id: i64, @@ -519,7 +519,7 @@ impl Display for Peer { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ChangeString { name: &'static str, old: Option, @@ -554,7 +554,7 @@ impl ChangeString { /// Encompasses the logic for comparing the peer configuration currently on the WireGuard interface /// to a (potentially) more current peer configuration from the innernet server. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct PeerDiff<'a> { pub old: Option<&'a PeerConfig>, pub new: Option<&'a Peer>, @@ -709,7 +709,7 @@ pub struct State { pub cidrs: Vec, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Timestring { timestring: String, seconds: u64, @@ -755,7 +755,7 @@ impl From for Duration { } } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Hostname(String); lazy_static! { diff --git a/wireguard-control/src/device.rs b/wireguard-control/src/device.rs index b07e37b..ca2c040 100644 --- a/wireguard-control/src/device.rs +++ b/wireguard-control/src/device.rs @@ -178,7 +178,7 @@ impl fmt::Display for InterfaceName { } /// An interface name was bad. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum InvalidInterfaceName { /// Provided name was longer then the interface name length limit /// of the system.