From 1e7f786994b561a8eddb6a81bad26939d009b43e Mon Sep 17 00:00:00 2001 From: creating2morrow Date: Sun, 7 May 2023 03:35:56 -0400 Subject: [PATCH] add i2p-zero to gui installation manager --- .gitignore | 2 ++ nevmes-core/src/lib.rs | 4 +++- nevmes-core/src/proof.rs | 4 ++-- nevmes-core/src/utils.rs | 19 +++++++++++++++++++ nevmes-gui/src/apps/home.rs | 8 ++++---- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 2b6d5b2..975aeaf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ monero-wallet-rpc.log notes.txt .vscode/settings.json *.bz2 +*.zip */monero-x86_64-linux-gnu-v0.18.2.2/** +*/i2p-zero-linux.v1.20/** diff --git a/nevmes-core/src/lib.rs b/nevmes-core/src/lib.rs index 92c374a..8f9ae3a 100644 --- a/nevmes-core/src/lib.rs +++ b/nevmes-core/src/lib.rs @@ -15,7 +15,9 @@ pub mod user; // user rep/service layer pub const NEVMES_JWP_SECRET_KEY: &str = "NEVMES_JWP_SECRET_KEY"; pub const NEVMES_JWT_SECRET_KEY: &str = "NEVMES_JWT_SECRET_KEY"; -// set the latest monero release download here +/// The latest monero release download pub const MONERO_RELEASE_VERSION: &str = "monero-linux-x64-v0.18.2.2.tar.bz2"; +/// The latest i2p-zero release version +pub const I2P_ZERO_RELEASE_VERSION: &str = "v1.20"; // DO NOT EDIT BELOW THIS LINE diff --git a/nevmes-core/src/proof.rs b/nevmes-core/src/proof.rs index c9a80b3..76c5830 100644 --- a/nevmes-core/src/proof.rs +++ b/nevmes-core/src/proof.rs @@ -241,9 +241,9 @@ async fn validate_proof(txp: &TxProof) -> TxProof { /// Validate that the subaddress in the proof was /// -/// created by us. TODO(c2m): Store the index for quicker +/// created by us. TODO(?): Use xmr rpc call `get_address_index` /// -/// lookups. +/// for faster lookups (check minor > 0) async fn validate_subaddress(subaddress: &String) -> bool { let m_address = monero::get_address().await; let all_address = m_address.result.addresses; diff --git a/nevmes-core/src/utils.rs b/nevmes-core/src/utils.rs index 5e45a0b..ab87780 100644 --- a/nevmes-core/src/utils.rs +++ b/nevmes-core/src/utils.rs @@ -422,6 +422,25 @@ pub async fn install_software(installations: Installations) { } if installations.i2p_zero { info!("installing i2p-zero"); + let i2p_version = crate::I2P_ZERO_RELEASE_VERSION; + let i2p_zero_zip = format!("i2p-zero-linux.{}.zip", i2p_version); + let link = format!("https://github.com/i2p-zero/i2p-zero/releases/download/{}/{}", + i2p_version, i2p_zero_zip); + let curl = std::process::Command::new("curl") + .args(["-LO#", &link]) + .status(); + match curl { + Ok(curl_output) => { + debug!("{:?}", curl_output); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + let unzip_output = std::process::Command::new("unzip") + .arg(i2p_zero_zip) + .spawn() + .expect("i2p unzip failed"); + debug!("{:?}", unzip_output.stdout); + }, + _=> error!("i2p-zero download failed") + } } if installations.xmr { info!("installing monero"); diff --git a/nevmes-gui/src/apps/home.rs b/nevmes-gui/src/apps/home.rs index b704b58..a576e36 100644 --- a/nevmes-gui/src/apps/home.rs +++ b/nevmes-gui/src/apps/home.rs @@ -218,14 +218,14 @@ impl eframe::App for HomeApp { .vscroll(true) .show(&ctx, |ui| { // let mut wants_i2p = self.installations.i2p; - // let mut wants_i2p_zero = self.installations.i2p_zero; + let mut wants_i2p_zero = self.installations.i2p_zero; let mut wants_xmr = self.installations.xmr; // if ui.checkbox(&mut wants_i2p, "i2p").changed() { // self.installations.i2p = !self.installations.i2p; // } - // if ui.checkbox(&mut wants_i2p_zero, "i2p-zero").changed() { - // self.installations.i2p_zero = !self.installations.i2p_zero; - // } + if ui.checkbox(&mut wants_i2p_zero, "i2p-zero").changed() { + self.installations.i2p_zero = !self.installations.i2p_zero; + } if ui.checkbox(&mut wants_xmr, "xmr").changed() { self.installations.xmr = !self.installations.xmr; }