Clean up bad port toggles
External nics are created pretty much only by port toggling these days.
After observing a few devices in the field I noticed that they had duplicated
the external nic into the peer interfaces list. It must not have been removed
properly. This should clean that up.
@@ -141,6 +141,7 @@ fn linux_init(config: Arc<RwLock<settings::client::RitaSettingsStruct>>) -> Resu
}
}
+ // generates a keypair if we don't already have a valid one
if wg_privkey_option.is_none() || wg_pubkey_option.is_none() {
info!("Existing wireguard keypair is invalid, generating from scratch");
let keypair = KI.create_wg_keypair().expect("failed to generate wg keys");
@@ -157,6 +158,15 @@ fn linux_init(config: Arc<RwLock<settings::client::RitaSettingsStruct>>) -> Resu
.expect("How did we get here without generating a key above?"),
)?;
+ // Sometimes due to a bad port toggle the external nic can still be populated
+ // as a peer_interface, this cleans that up.
+ if let Some(external_nic) = network_settings.external_nic.clone() {
+ let res = network_settings.peer_interfaces.remove(&external_nic);
+ if res {
+ warn!("Duplicate interface removed!");
+ }
+ }
+
// Yield the mut lock
drop(network_settings);
