1
0
mirror of https://github.com/tonarino/innernet.git synced 2025-01-24 05:16:32 +02:00

client(install): bail if WireGuard interface with same name exists

Closes #113
This commit is contained in:
Jake McGinty 2021-08-02 23:06:13 +09:00
parent 40e8ca68f9
commit 61b055c44b

View File

@ -284,7 +284,10 @@ fn install(
let target_conf = CLIENT_CONFIG_DIR.join(&iface).with_extension("conf"); let target_conf = CLIENT_CONFIG_DIR.join(&iface).with_extension("conf");
if target_conf.exists() { if target_conf.exists() {
bail!("An interface with this name already exists in innernet."); bail!("An existing innernet network with the name \"{}\" already exists.", iface);
}
if Device::list(network.backend)?.iter().any(|name| name.as_str_lossy() == iface) {
bail!("An existing WireGuard interface with the name \"{}\" already exists.", iface);
} }
let iface = iface.parse()?; let iface = iface.parse()?;