diff --git a/server/src/initialize.rs b/server/src/initialize.rs index 3267978..7b9b7f5 100644 --- a/server/src/initialize.rs +++ b/server/src/initialize.rs @@ -143,13 +143,11 @@ pub fn init_wizard(conf: &ServerConfig, opts: InitializeOpts) -> Result<(), Erro let endpoint: Endpoint = if let Some(endpoint) = opts.external_endpoint { endpoint + } else if opts.auto_external_endpoint { + let ip = publicip::get_any(Preference::Ipv4)?.ok_or("couldn't get external IP")?; + SocketAddr::new(ip, 51820).into() } else { - if opts.auto_external_endpoint { - let ip = publicip::get_any(Preference::Ipv4)?.ok_or("couldn't get external IP")?; - SocketAddr::new(ip, 51820).into() - } else { - prompts::ask_endpoint()? - } + prompts::ask_endpoint()? }; let listen_port: u16 = if let Some(listen_port) = opts.listen_port { diff --git a/server/src/main.rs b/server/src/main.rs index 841f47b..1cf382d 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -204,7 +204,7 @@ async fn main() -> Result<(), Box> { if let Err(e) = initialize::init_wizard(&conf, opts) { println!("{}: {}.", "creation failed".red(), e); } - }, + } Command::Uninstall { interface } => uninstall(&interface, &conf)?, Command::Serve { interface } => serve(*interface, &conf).await?, Command::AddPeer { interface, args } => add_peer(&interface, &conf, args)?, @@ -402,8 +402,8 @@ async fn serve(interface: InterfaceName, conf: &ServerConfig) -> Result<(), Erro let context = Context { db, - interface, endpoints, + interface, public_key, }; diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 78d3c20..691f826 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -35,7 +35,7 @@ pub fn ensure_dirs_exist(dirs: &[&Path]) -> Result<(), WrappedIoError> { for dir in dirs { match fs::create_dir(dir).with_path(dir) { Err(e) if e.kind() != io::ErrorKind::AlreadyExists => { - return Err(e.into()); + return Err(e); } _ => { let target_file = File::open(dir).with_path(dir)?;