Reset wireguard pub key after private key import, release write locks
@@ -38,13 +38,27 @@ pub fn set_eth_private_key(data: Json<EthPrivateKey>) -> Result<HttpResponse, Er
debug!("/eth_private_key POST hit");
let pk: PrivateKey = data.into_inner().eth_private_key.parse()?;
- SETTING.get_payment_mut().eth_private_key = Some(pk);
- SETTING.get_payment_mut().eth_address = Some(pk.to_public_key()?);
- let mut exits = SETTING.get_exits_mut();
- for mut exit in exits.iter_mut() {
+ let mut payment_settings = SETTING.get_payment_mut();
+ payment_settings.eth_private_key = Some(pk);
+ payment_settings.eth_address = Some(pk.to_public_key()?);
+ drop(payment_settings);
+
+ // remove the wg_public_key to force exit re-registration
+ let mut network_settings = SETTING.get_network_mut();
+ network_settings.wg_public_key = None;
+ drop(network_settings);
+
+ // unset current exit
+ let mut exit_client_settings = SETTING.get_exit_client_mut();
+ exit_client_settings.current_exit = None;
+ drop(exit_client_settings);
+
+ let mut exit_settings = SETTING.get_exits_mut();
+ for mut exit in exit_settings.iter_mut() {
exit.1.info = ExitState::New;
}
+ drop(exit_settings);
// try and save the config and fail if we can't
if let Err(e) = SETTING.write().unwrap().write(&ARGS.flag_config) {
