Fix private key importing
We really do need to reboot here, no a process restart will not suffice
@@ -4,7 +4,6 @@ use crate::SETTING;
use actix_web::{HttpRequest, HttpResponse, Json};
use althea_types::ExitState;
use clarity::PrivateKey;
-use clu::linux_generate_mesh_ip;
use failure::Error;
use settings::client::RitaClientSettings;
use settings::FileWrite;
@@ -26,7 +25,7 @@ pub fn get_eth_private_key(_req: HttpRequest) -> Result<HttpResponse, Error> {
ret.insert("eth_private_key".to_owned(), format!("{:x}", pk));
}
None => {
- let error_msg = "No mesh IP configured yet";
+ let error_msg = "No eth key configured yet";
warn!("{}", error_msg);
ret.insert("error".to_owned(), error_msg.to_owned());
}
@@ -45,20 +44,14 @@ pub fn set_eth_private_key(data: Json<EthPrivateKey>) -> Result<HttpResponse, Er
payment_settings.eth_address = Some(pk.to_public_key()?);
drop(payment_settings);
- // remove the wg_public_key and regenerate mesh_ip to force exit re-registration
+ // remove the wg_public_key and regenerate wg private key, we don't do that here
+ // so it will happen on process restart. We could just call the linux client init
+ // from clu but we would need to handle already deployed tunnels and it's just not
+ // worth the trouble.
let mut network_settings = SETTING.get_network_mut();
+ network_settings.wg_private_key = None;
network_settings.wg_public_key = None;
-
- match linux_generate_mesh_ip() {
- Ok(ip) => {
- network_settings.mesh_ip = Some(ip);
- }
- Err(e) => {
- warn!("Unable to generate new mesh IP: {:?}", e);
- return Err(e);
- }
- }
-
+ network_settings.mesh_ip = None;
drop(network_settings);
// unset current exit
@@ -77,8 +70,8 @@ pub fn set_eth_private_key(data: Json<EthPrivateKey>) -> Result<HttpResponse, Er
return Err(e);
}
- // it's now safe to restart the process, return an error if that fails somehow
- if let Err(e) = KI.run_command("/etc/init.d/rita", &["restart"]) {
+ // it's now safe to reboot the router
+ if let Err(e) = KI.run_command("reboot", &[]) {
return Err(e);
}
