meta: appease clippy

pull/239/head
Jake McGinty 2022-08-10 16:39:09 -06:00
parent c9dbeefaaa
commit 1fb5874527
6 changed files with 25 additions and 27 deletions

View File

@ -80,7 +80,7 @@ struct HostsOpt {
impl From<HostsOpt> for Option<PathBuf> {
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)

View File

@ -26,7 +26,7 @@ fn create_database<P: AsRef<Path>>(
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)]

View File

@ -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),

View File

@ -93,10 +93,8 @@ pub fn _get_local_addrs() -> Result<impl Iterator<Item = std::net::IpAddr>, 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()))
}
})
});

View File

@ -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<Timestring>,
}
#[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<String>,
@ -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<u32>,
}
#[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<Endpoint>,
}
#[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<String>,
@ -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<Cidr>,
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Timestring {
timestring: String,
seconds: u64,
@ -755,7 +755,7 @@ impl From<Timestring> for Duration {
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Hostname(String);
lazy_static! {

View File

@ -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.