meta: appease clippy
parent
c9dbeefaaa
commit
1fb5874527
|
@ -80,7 +80,7 @@ struct HostsOpt {
|
||||||
|
|
||||||
impl From<HostsOpt> for Option<PathBuf> {
|
impl From<HostsOpt> for Option<PathBuf> {
|
||||||
fn from(opt: HostsOpt) -> Self {
|
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 {
|
for iface in interfaces {
|
||||||
fetch(&*iface, opts, true, hosts_path.clone(), nat)?;
|
fetch(&iface, opts, true, hosts_path.clone(), nat)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
match loop_interval {
|
match loop_interval {
|
||||||
|
@ -725,7 +725,7 @@ fn delete_cidr(
|
||||||
let cidr_id = prompts::delete_cidr(&cidrs, &peers, &sub_opts)?;
|
let cidr_id = prompts::delete_cidr(&cidrs, &peers, &sub_opts)?;
|
||||||
|
|
||||||
println!("Deleting CIDR...");
|
println!("Deleting CIDR...");
|
||||||
api.http("DELETE", &*format!("/admin/cidrs/{}", cidr_id))?;
|
api.http("DELETE", &format!("/admin/cidrs/{}", cidr_id))?;
|
||||||
|
|
||||||
println!("CIDR deleted.");
|
println!("CIDR deleted.");
|
||||||
|
|
||||||
|
@ -966,7 +966,7 @@ fn override_endpoint(
|
||||||
};
|
};
|
||||||
|
|
||||||
let endpoint_contents = if sub_opts.unset {
|
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 {
|
} else {
|
||||||
let endpoint = prompts::override_endpoint(&sub_opts, port)?;
|
let endpoint = prompts::override_endpoint(&sub_opts, port)?;
|
||||||
endpoint.map(EndpointContents::Set)
|
endpoint.map(EndpointContents::Set)
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn create_database<P: AsRef<Path>>(
|
||||||
Ok(conn)
|
Ok(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Parser)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Parser)]
|
||||||
pub struct InitializeOpts {
|
pub struct InitializeOpts {
|
||||||
/// The network name (ex: evilcorp)
|
/// The network name (ex: evilcorp)
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
|
|
@ -341,7 +341,7 @@ fn add_peer(
|
||||||
(&mut target_file, &target_path),
|
(&mut target_file, &target_path),
|
||||||
interface,
|
interface,
|
||||||
&peer,
|
&peer,
|
||||||
&*server_peer,
|
&server_peer,
|
||||||
&cidr_tree,
|
&cidr_tree,
|
||||||
keypair,
|
keypair,
|
||||||
&SocketAddr::new(config.address, config.listen_port),
|
&SocketAddr::new(config.address, config.listen_port),
|
||||||
|
|
|
@ -93,10 +93,8 @@ pub fn _get_local_addrs() -> Result<impl Iterator<Item = std::net::IpAddr>, io::
|
||||||
interface_addr.address.and_then(|addr| {
|
interface_addr.address.and_then(|addr| {
|
||||||
if let Some(sockaddr_in) = addr.as_sockaddr_in() {
|
if let Some(sockaddr_in) = addr.as_sockaddr_in() {
|
||||||
Some(IpAddr::V4(Ipv4Addr::from(sockaddr_in.ip())))
|
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 {
|
} else {
|
||||||
None
|
addr.as_sockaddr_in6().map(|sockaddr_in6| IpAddr::V6(sockaddr_in6.ip()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,7 @@ use wireguard_control::{
|
||||||
|
|
||||||
use crate::wg::PeerInfoExt;
|
use crate::wg::PeerInfoExt;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Interface {
|
pub struct Interface {
|
||||||
name: InterfaceName,
|
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.
|
/// An external endpoint that supports both IP and domain name hosts.
|
||||||
pub struct Endpoint {
|
pub struct Endpoint {
|
||||||
host: Host,
|
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 struct RedeemContents {
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct InstallOpts {
|
pub struct InstallOpts {
|
||||||
/// Set a specific interface name
|
/// Set a specific interface name
|
||||||
#[clap(long, conflicts_with = "default-name")]
|
#[clap(long, conflicts_with = "default-name")]
|
||||||
|
@ -298,7 +298,7 @@ pub struct InstallOpts {
|
||||||
pub delete_invite: bool,
|
pub delete_invite: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct AddPeerOpts {
|
pub struct AddPeerOpts {
|
||||||
/// Name of new peer
|
/// Name of new peer
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -333,7 +333,7 @@ pub struct AddPeerOpts {
|
||||||
pub invite_expires: Option<Timestring>,
|
pub invite_expires: Option<Timestring>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct RenamePeerOpts {
|
pub struct RenamePeerOpts {
|
||||||
/// Name of peer to rename
|
/// Name of peer to rename
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -348,7 +348,7 @@ pub struct RenamePeerOpts {
|
||||||
pub yes: bool,
|
pub yes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct AddCidrOpts {
|
pub struct AddCidrOpts {
|
||||||
/// The CIDR name (eg. 'engineers')
|
/// The CIDR name (eg. 'engineers')
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -367,7 +367,7 @@ pub struct AddCidrOpts {
|
||||||
pub yes: bool,
|
pub yes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct DeleteCidrOpts {
|
pub struct DeleteCidrOpts {
|
||||||
/// The CIDR name (eg. 'engineers')
|
/// The CIDR name (eg. 'engineers')
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -378,7 +378,7 @@ pub struct DeleteCidrOpts {
|
||||||
pub yes: bool,
|
pub yes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct AddDeleteAssociationOpts {
|
pub struct AddDeleteAssociationOpts {
|
||||||
/// The first cidr to associate
|
/// The first cidr to associate
|
||||||
pub cidr1: Option<String>,
|
pub cidr1: Option<String>,
|
||||||
|
@ -391,7 +391,7 @@ pub struct AddDeleteAssociationOpts {
|
||||||
pub yes: bool,
|
pub yes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct ListenPortOpts {
|
pub struct ListenPortOpts {
|
||||||
/// The listen port you'd like to set for the interface
|
/// The listen port you'd like to set for the interface
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
|
@ -406,7 +406,7 @@ pub struct ListenPortOpts {
|
||||||
pub yes: bool,
|
pub yes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Eq, Args)]
|
||||||
pub struct OverrideEndpointOpts {
|
pub struct OverrideEndpointOpts {
|
||||||
/// The listen port you'd like to set for the interface
|
/// The listen port you'd like to set for the interface
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
|
@ -475,7 +475,7 @@ pub struct NetworkOpts {
|
||||||
pub mtu: Option<u32>,
|
pub mtu: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct PeerContents {
|
pub struct PeerContents {
|
||||||
pub name: Hostname,
|
pub name: Hostname,
|
||||||
pub ip: IpAddr,
|
pub ip: IpAddr,
|
||||||
|
@ -491,7 +491,7 @@ pub struct PeerContents {
|
||||||
pub candidates: Vec<Endpoint>,
|
pub candidates: Vec<Endpoint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Peer {
|
pub struct Peer {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ impl Display for Peer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct ChangeString {
|
pub struct ChangeString {
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
old: Option<String>,
|
old: Option<String>,
|
||||||
|
@ -554,7 +554,7 @@ impl ChangeString {
|
||||||
|
|
||||||
/// Encompasses the logic for comparing the peer configuration currently on the WireGuard interface
|
/// Encompasses the logic for comparing the peer configuration currently on the WireGuard interface
|
||||||
/// to a (potentially) more current peer configuration from the innernet server.
|
/// 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 struct PeerDiff<'a> {
|
||||||
pub old: Option<&'a PeerConfig>,
|
pub old: Option<&'a PeerConfig>,
|
||||||
pub new: Option<&'a Peer>,
|
pub new: Option<&'a Peer>,
|
||||||
|
@ -709,7 +709,7 @@ pub struct State {
|
||||||
pub cidrs: Vec<Cidr>,
|
pub cidrs: Vec<Cidr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct Timestring {
|
pub struct Timestring {
|
||||||
timestring: String,
|
timestring: String,
|
||||||
seconds: u64,
|
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);
|
pub struct Hostname(String);
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
|
@ -178,7 +178,7 @@ impl fmt::Display for InterfaceName {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An interface name was bad.
|
/// An interface name was bad.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum InvalidInterfaceName {
|
pub enum InvalidInterfaceName {
|
||||||
/// Provided name was longer then the interface name length limit
|
/// Provided name was longer then the interface name length limit
|
||||||
/// of the system.
|
/// of the system.
|
||||||
|
|
Loading…
Reference in New Issue