Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
linuskendall committed Dec 12, 2023
1 parent c402798 commit d451bb8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
14 changes: 7 additions & 7 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use shared::{
prompts,
wg::{DeviceExt, PeerInfoExt},
AddCidrOpts, AddDeleteAssociationOpts, AddPeerOpts, Association, AssociationContents, Cidr,
CidrTree, DeleteCidrOpts, Endpoint, EndpointContents, InstallOpts, Interface, IoErrorContext,
ListenPortOpts, NatOpts, NetworkOpts, OverrideEndpointOpts, Peer, RedeemContents,
RenamePeerOpts, EnableDisablePeerOpts, State, WrappedIoError, REDEEM_TRANSITION_WAIT,
CidrTree, DeleteCidrOpts, EnableDisablePeerOpts, Endpoint, EndpointContents, InstallOpts,
Interface, IoErrorContext, ListenPortOpts, NatOpts, NetworkOpts, OverrideEndpointOpts, Peer,
RedeemContents, RenamePeerOpts, State, WrappedIoError, REDEEM_TRANSITION_WAIT,
};
use std::{
fmt, io,
Expand Down Expand Up @@ -212,15 +212,15 @@ enum Command {
},

/// Disable an enabled peer
DisablePeer {
DisablePeer {
interface: Interface,

#[clap(flatten)]
sub_opts: EnableDisablePeerOpts,
},

/// Enable a disabled peer
EnablePeer {
EnablePeer {
interface: Interface,

#[clap(flatten)]
Expand Down Expand Up @@ -1262,11 +1262,11 @@ fn run(opts: &Opts) -> Result<(), Error> {
sub_opts,
} => delete_cidr(&interface, opts, sub_opts)?,
Command::ListCidrs { interface, tree } => list_cidrs(&interface, opts, tree)?,
Command::DisablePeer {
Command::DisablePeer {
interface,
sub_opts,
} => enable_or_disable_peer(&interface, opts, sub_opts, false)?,
Command::EnablePeer {
Command::EnablePeer {
interface,
sub_opts,
} => enable_or_disable_peer(&interface, opts, sub_opts, true)?,
Expand Down
12 changes: 6 additions & 6 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use parking_lot::{Mutex, RwLock};
use rusqlite::Connection;
use serde::{Deserialize, Serialize};
use shared::{
get_local_addrs, AddCidrOpts, AddPeerOpts, DeleteCidrOpts, Endpoint, IoErrorContext,
NetworkOpts, PeerContents, RenamePeerOpts, EnableDisablePeerOpts, INNERNET_PUBKEY_HEADER,
get_local_addrs, AddCidrOpts, AddPeerOpts, DeleteCidrOpts, EnableDisablePeerOpts, Endpoint,
IoErrorContext, NetworkOpts, PeerContents, RenamePeerOpts, INNERNET_PUBKEY_HEADER,
};
use std::{
collections::{HashMap, VecDeque},
Expand Down Expand Up @@ -96,20 +96,20 @@ enum Command {
},

/// Disable an enabled peer
DisablePeer {
DisablePeer {
interface: Interface,

#[clap(flatten)]
args: EnableDisablePeerOpts,
},

/// Enable a disabled peer
EnablePeer {
EnablePeer {
interface: Interface,

#[clap(flatten)]
args: EnableDisablePeerOpts,
},
},

/// Rename an existing peer.
RenamePeer {
Expand Down
12 changes: 8 additions & 4 deletions shared/src/prompts.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
interface_config::{InterfaceConfig, InterfaceInfo, ServerInfo},
AddCidrOpts, AddDeleteAssociationOpts, AddPeerOpts, Association, Cidr, CidrContents, CidrTree,
DeleteCidrOpts, Endpoint, Error, Hostname, IpNetExt, ListenPortOpts, OverrideEndpointOpts,
Peer, PeerContents, RenamePeerOpts, EnableDisablePeerOpts, PERSISTENT_KEEPALIVE_INTERVAL_SECS,
DeleteCidrOpts, EnableDisablePeerOpts, Endpoint, Error, Hostname, IpNetExt, ListenPortOpts,
OverrideEndpointOpts, Peer, PeerContents, RenamePeerOpts, PERSISTENT_KEEPALIVE_INTERVAL_SECS,
};
use anyhow::anyhow;
use colored::*;
Expand Down Expand Up @@ -396,7 +396,11 @@ pub fn rename_peer(

/// Presents a selection and confirmation of eligible peers for either disabling or enabling,
/// and returns back the ID of the selected peer.
pub fn enable_or_disable_peer(peers: &[Peer], args: &EnableDisablePeerOpts, enable: bool) -> Result<Option<Peer>, Error> {
pub fn enable_or_disable_peer(
peers: &[Peer],
args: &EnableDisablePeerOpts,
enable: bool,
) -> Result<Option<Peer>, Error> {
let enabled_peers: Vec<_> = peers
.iter()
.filter(|peer| enable && peer.is_disabled || !enable && !peer.is_disabled)
Expand Down Expand Up @@ -426,7 +430,7 @@ pub fn enable_or_disable_peer(peers: &[Peer], args: &EnableDisablePeerOpts, enab
"{}able peer {}?",
if enable { "En" } else { "Dis" },
peer.name.yellow()
))?
))?
{
Some(peer.clone())
} else {
Expand Down
1 change: 0 additions & 1 deletion shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ pub struct RenamePeerOpts {
pub yes: bool,
}


#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct EnableDisablePeerOpts {
/// Name of peer to enable/disable
Expand Down

0 comments on commit d451bb8

Please sign in to comment.