parent
17dd26921f
commit
d7cf24c63c
|
@ -5,7 +5,7 @@ use dialoguer::{theme::ColorfulTheme, Input};
|
|||
use indoc::printdoc;
|
||||
use publicip::Preference;
|
||||
use rusqlite::{params, Connection};
|
||||
use shared::{prompts, CidrContents, Endpoint, PeerContents, PERSISTENT_KEEPALIVE_INTERVAL_SECS};
|
||||
use shared::{CidrContents, Endpoint, PERSISTENT_KEEPALIVE_INTERVAL_SECS, PeerContents, prompts};
|
||||
use wireguard_control::KeyPair;
|
||||
|
||||
fn create_database<P: AsRef<Path>>(
|
||||
|
@ -26,7 +26,7 @@ fn create_database<P: AsRef<Path>>(
|
|||
pub struct InitializeOpts {
|
||||
/// The network name (ex: evilcorp)
|
||||
#[structopt(long)]
|
||||
pub network_name: Option<InterfaceName>,
|
||||
pub network_name: Option<Interface>,
|
||||
|
||||
/// The network CIDR (ex: 10.42.0.0/16)
|
||||
#[structopt(long)]
|
||||
|
@ -122,7 +122,7 @@ pub fn init_wizard(conf: &ServerConfig, opts: InitializeOpts) -> Result<(), Erro
|
|||
\n"
|
||||
);
|
||||
|
||||
let name: InterfaceName = if let Some(name) = opts.network_name {
|
||||
let name: Interface = if let Some(name) = opts.network_name {
|
||||
name
|
||||
} else {
|
||||
Input::with_theme(&theme)
|
||||
|
|
|
@ -3,16 +3,7 @@ use ipnetwork::IpNetwork;
|
|||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
fmt::{self, Display, Formatter},
|
||||
io,
|
||||
net::{IpAddr, SocketAddr, ToSocketAddrs},
|
||||
ops::{Deref, DerefMut},
|
||||
path::Path,
|
||||
str::FromStr,
|
||||
time::{Duration, SystemTime},
|
||||
vec,
|
||||
};
|
||||
use std::{fmt::{self, Display, Formatter}, io, net::{IpAddr, SocketAddr, ToSocketAddrs}, ops::{Deref, DerefMut}, path::Path, str::FromStr, time::{Duration, SystemTime}, vec};
|
||||
use structopt::StructOpt;
|
||||
use url::Host;
|
||||
use wireguard_control::{
|
||||
|
@ -22,7 +13,7 @@ use wireguard_control::{
|
|||
|
||||
use crate::wg::PeerInfoExt;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Interface {
|
||||
name: InterfaceName,
|
||||
}
|
||||
|
@ -49,6 +40,12 @@ impl Deref for Interface {
|
|||
}
|
||||
}
|
||||
|
||||
impl Display for Interface {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(&self.name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
/// An external endpoint that supports both IP and domain name hosts.
|
||||
pub struct Endpoint {
|
||||
|
|
Loading…
Reference in New Issue