client(install): fix install check failure when /var/run/wireguard doesn't exist

pull/127/head
Jake McGinty 2021-08-03 00:44:06 +09:00
parent 82325509db
commit 89f2e813cf
1 changed files with 4 additions and 3 deletions

View File

@ -289,9 +289,11 @@ fn install(
iface iface
); );
} }
if Device::list(network.backend)? let iface = iface.parse()?;
if Device::list(network.backend)
.iter() .iter()
.any(|name| name.as_str_lossy() == iface) .flatten()
.any(|name| name == &iface)
{ {
bail!( bail!(
"An existing WireGuard interface with the name \"{}\" already exists.", "An existing WireGuard interface with the name \"{}\" already exists.",
@ -299,7 +301,6 @@ fn install(
); );
} }
let iface = iface.parse()?;
redeem_invite(&iface, config, target_conf, network).map_err(|e| { redeem_invite(&iface, config, target_conf, network).map_err(|e| {
log::error!("failed to start the interface: {}.", e); log::error!("failed to start the interface: {}.", e);
log::info!("bringing down the interface."); log::info!("bringing down the interface.");