diff --git a/client/src/main.rs b/client/src/main.rs
index 909739f..04cd38a 100644
--- a/client/src/main.rs
+++ b/client/src/main.rs
@@ -657,8 +657,7 @@ fn add_peer(interface: &InterfaceName, opts: AddPeerOpts) -> Result<(), Error> {
let peer: Peer = api.http_form("POST", "/admin/peers", peer_request)?;
let server_peer = peers.iter().find(|p| p.id == 1).unwrap();
prompts::write_peer_invitation(
- &mut target_file,
- &target_path,
+ (&mut target_file, &target_path),
interface,
&peer,
server_peer,
@@ -688,7 +687,7 @@ fn rename_peer(interface: &InterfaceName, opts: RenamePeerOpts) -> Result<(), Er
.filter(|p| p.name == old_name)
.map(|p| p.id)
.next()
- .ok_or(anyhow!("Peer not found."))?;
+ .ok_or_else(|| anyhow!("Peer not found."))?;
let _ = api.http_form("PUT", &format!("/admin/peers/{}", id), peer_request)?;
log::info!("Peer renamed.");
@@ -728,11 +727,11 @@ fn add_association(interface: &InterfaceName, opts: AddAssociationOpts) -> Resul
let cidr1 = cidrs
.iter()
.find(|c| &c.name == cidr1)
- .ok_or(anyhow!("can't find cidr '{}'", cidr1))?;
+ .ok_or_else(|| anyhow!("can't find cidr '{}'", cidr1))?;
let cidr2 = cidrs
.iter()
.find(|c| &c.name == cidr2)
- .ok_or(anyhow!("can't find cidr '{}'", cidr2))?;
+ .ok_or_else(|| anyhow!("can't find cidr '{}'", cidr2))?;
(cidr1, cidr2)
} else if let Some((cidr1, cidr2)) = prompts::add_association(&cidrs[..])? {
(cidr1, cidr2)
@@ -889,7 +888,7 @@ fn show(
let me = peers
.iter()
.find(|p| p.public_key == device_info.public_key.as_ref().unwrap().to_base64())
- .ok_or(anyhow!("missing peer info"))?;
+ .ok_or_else(|| anyhow!("missing peer info"))?;
let mut peer_states = device_info
.peers
diff --git a/client/src/util.rs b/client/src/util.rs
index 3684c76..310fbe8 100644
--- a/client/src/util.rs
+++ b/client/src/util.rs
@@ -3,7 +3,7 @@ use colored::*;
use indoc::eprintdoc;
use log::{Level, LevelFilter};
use serde::{de::DeserializeOwned, Serialize};
-use shared::{interface_config::ServerInfo, WrappedIoError, INNERNET_PUBKEY_HEADER};
+use shared::{interface_config::ServerInfo, INNERNET_PUBKEY_HEADER};
use std::{io, time::Duration};
use ureq::{Agent, AgentBuilder};
diff --git a/server/src/initialize.rs b/server/src/initialize.rs
index 23cafdc..1b4e20d 100644
--- a/server/src/initialize.rs
+++ b/server/src/initialize.rs
@@ -140,7 +140,8 @@ 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(anyhow!("couldn't get external IP"))?;
+ let ip = publicip::get_any(Preference::Ipv4)
+ .ok_or_else(|| anyhow!("couldn't get external IP"))?;
SocketAddr::new(ip, 51820).into()
} else {
prompts::ask_endpoint()?
diff --git a/server/src/main.rs b/server/src/main.rs
index 038209e..baeb399 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -308,8 +308,7 @@ fn add_peer(
let server_peer = DatabasePeer::get(&conn, 1)?;
prompts::write_peer_invitation(
- &mut target_file,
- &target_path,
+ (&mut target_file, &target_path),
interface,
&peer,
&*server_peer,
@@ -339,7 +338,7 @@ fn rename_peer(
let mut db_peer = DatabasePeer::list(&conn)?
.into_iter()
.find(|p| p.name == old_name)
- .ok_or(anyhow!("Peer not found."))?;
+ .ok_or_else(|| anyhow!("Peer not found."))?;
let _peer = db_peer.update(&conn, peer_request)?;
} else {
println!("exited without creating peer.");
diff --git a/shared/src/prompts.rs b/shared/src/prompts.rs
index 306c491..a3e4d80 100644
--- a/shared/src/prompts.rs
+++ b/shared/src/prompts.rs
@@ -80,7 +80,7 @@ pub fn add_cidr(cidrs: &[Cidr], request: &AddCidrOpts) -> Result