Skip to content

Commit

Permalink
meta: appease clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mcginty committed Aug 10, 2022
1 parent c9dbeef commit 1fb5874
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
8 changes: 4 additions & 4 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.");

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion server/src/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 1 addition & 3 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
})
});
Expand Down
34 changes: 17 additions & 17 deletions shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")]
Expand All @@ -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)]
Expand Down Expand Up @@ -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)]
Expand All @@ -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)]
Expand All @@ -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)]
Expand All @@ -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>,
Expand All @@ -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)]
Expand All @@ -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)]
Expand Down Expand Up @@ -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,
Expand All @@ -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,

Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion wireguard-control/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1fb5874

Please sign in to comment.