From b8505d3c4e96223edbb3029f95119ba6a996e64d Mon Sep 17 00:00:00 2001 From: creating2morrow Date: Wed, 28 Jun 2023 21:08:18 -0400 Subject: [PATCH] create socks proxy with --i2p-socks-proxy-host cli arg --- neveko-core/src/args.rs | 6 ++++- neveko-core/src/i2p.rs | 22 ++++++++----------- neveko-core/src/monero.rs | 46 ++++++++++++++++++++++----------------- neveko-core/src/utils.rs | 1 - 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/neveko-core/src/args.rs b/neveko-core/src/args.rs index cdb745d..7d70103 100644 --- a/neveko-core/src/args.rs +++ b/neveko-core/src/args.rs @@ -170,6 +170,10 @@ pub struct Args { )] pub i2p_normal: bool, /// i2p anonymous inbound port - #[arg(long, help = "Set i2p anon inbound connectivity", default_value = "38089")] + #[arg( + long, + help = "Set i2p anon inbound connectivity", + default_value = "38089" + )] pub anon_inbound_port: u16, } diff --git a/neveko-core/src/i2p.rs b/neveko-core/src/i2p.rs index 7ec95b3..5969f42 100644 --- a/neveko-core/src/i2p.rs +++ b/neveko-core/src/i2p.rs @@ -74,11 +74,11 @@ async fn find_tunnels() { debug!("i2p tunnels: {}", contents); let has_app_tunnel = contents.contains(&format!("{}", app_port)); let proxy_port = get_i2p_proxy_port(); - let tx_proxy_port = monero::get_daemon_port(); + let socks_proxy_port = get_i2p_socks_proxy_port(); let has_http_tunnel = contents.contains(&proxy_port); - let has_tx_proxy_tunnel = contents.contains(&format!("{}", &tx_proxy_port)); + let has_socks_proxy_tunnel = contents.contains(&format!("{}", &socks_proxy_port)); let has_anon_inbound_tunnel = contents.contains(&format!("{}", args.anon_inbound_port)); - if !has_app_tunnel || !has_http_tunnel || !has_anon_inbound_tunnel { + if !has_app_tunnel || !has_http_tunnel || !has_anon_inbound_tunnel || !has_socks_proxy_tunnel { tokio::time::sleep(Duration::new(120, 0)).await; } if !has_app_tunnel { @@ -93,13 +93,9 @@ async fn find_tunnels() { debug!("creating anon inbound tunnel"); create_anon_inbound_tunnel(); } - let env = utils::get_release_env(); - // only use tx proxy on mainnet - if env == utils::ReleaseEnvironment::Production { - if !has_tx_proxy_tunnel && !utils::is_using_remote_node() { - debug!("creating tx proxy tunnel"); - create_tx_proxy_tunnel(); - } + if !has_socks_proxy_tunnel { + debug!("creating socks proxy tunnel"); + create_tx_proxy_tunnel(); } } @@ -146,9 +142,9 @@ fn create_tunnel() { debug!("{:?}", output.stdout); } -/// Create an i2p tunnel for the monero tx proxy +/// Create an i2p tunnel for the monero wallet socks proxy fn create_tx_proxy_tunnel() { - info!("creating monerod tx proxy tunnel"); + info!("creating monerod socks proxy tunnel"); let args = args::Args::parse(); let path = args.i2p_zero_dir; let output = Command::new(format!("{}/router/bin/tunnel-control.sh", path)) @@ -158,7 +154,7 @@ fn create_tx_proxy_tunnel() { &format!("{}", get_i2p_socks_proxy_port()), ]) .spawn() - .expect("i2p-zero failed to create a tx proxy tunnel"); + .expect("i2p-zero failed to create a socks proxy tunnel"); debug!("{:?}", output.stdout); } diff --git a/neveko-core/src/monero.rs b/neveko-core/src/monero.rs index fef96c0..6c900a3 100644 --- a/neveko-core/src/monero.rs +++ b/neveko-core/src/monero.rs @@ -193,9 +193,15 @@ pub fn start_rpc() { let rpc_login = format!("{}:{}", &login.username, &login.credential); let release_env = utils::get_release_env(); let is_dev = release_env == utils::ReleaseEnvironment::Development; - let wallet_path = if is_dev { ".neveko/stagenet/wallet/" } else { ".neveko/wallet/" }; + let wallet_path = if is_dev { + ".neveko/stagenet/wallet/" + } else { + ".neveko/wallet/" + }; let wallet_dir = format!( - "/home/{}/{}", std::env::var("USER").unwrap_or(String::from("user")), wallet_path + "/home/{}/{}", + std::env::var("USER").unwrap_or(String::from("user")), + wallet_path ); if cli_args.remote_node && !&daemon_address.contains(".i2p") { warn!("invalid i2p monero remote node detected"); @@ -208,24 +214,24 @@ pub fn start_rpc() { proxy_host = v.remove(1); } let mut args = vec![ - "--rpc-bind-port", - &port, - "--wallet-dir", - &wallet_dir, - "--rpc-login", - &rpc_login, - ]; - if cli_args.remote_node { - args.push("--proxy"); - args.push(&proxy_host); - args.push("--daemon-address"); - args.push(&daemon_address); - args.push("--trusted-daemon"); - args.push("--daemon-ssl-allow-any-cert"); - } else { - args.push("--daemon-address"); - args.push(&daemon_address); - } + "--rpc-bind-port", + &port, + "--wallet-dir", + &wallet_dir, + "--rpc-login", + &rpc_login, + ]; + if cli_args.remote_node { + args.push("--proxy"); + args.push(&proxy_host); + args.push("--daemon-address"); + args.push(&daemon_address); + args.push("--trusted-daemon"); + args.push("--daemon-ssl-allow-any-cert"); + } else { + args.push("--daemon-address"); + args.push(&daemon_address); + } if is_dev { args.push("--stagenet"); let output = Command::new(format!("{}/monero-wallet-rpc", bin_dir)) diff --git a/neveko-core/src/utils.rs b/neveko-core/src/utils.rs index 6971c8b..7792bc1 100644 --- a/neveko-core/src/utils.rs +++ b/neveko-core/src/utils.rs @@ -242,7 +242,6 @@ pub fn get_i2p_wallet_proxy_host() -> String { args.i2p_socks_proxy_host } - /// app auth port pub fn get_app_auth_port() -> u16 { let args = args::Args::parse();