diff --git a/Cargo.toml b/Cargo.toml index 4983f2d..02a43b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,6 @@ distro = [] [dependencies] anyhow = "1.0.80" -arti-client = { version = "0.14.0", features = ["static"] } -arti-hyper = "0.14.0" benri = "0.1.12" bytes = "1.5.0" dirs = "5.0.1" @@ -60,7 +58,7 @@ eframe = { version = "0.26.2", features = ["wgpu"] } #-------------------------------------------------------------------------------- env_logger = "0.11.2" figment = { version = "0.10.14", features = ["toml"] } -hyper = "0.14.28" +hyper = {version="0.14.28", features=["client", "http1"]} hyper-tls = "0.5.0" image = { version = "0.24.9", features = ["png"] } log = "0.4.20" @@ -76,7 +74,6 @@ sysinfo = { version = "0.30.5", default-features = false } tls-api = "0.9.0" tokio = { version = "1.36.0", features = ["rt", "time", "macros", "process"] } toml = { version = "0.8.10", features = ["preserve_order"] } -tor-rtcompat = "0.10.0" walkdir = "2.4.0" zeroize = "1.7.0" strsim = "0.11.0" diff --git a/TODO_XMRvsBeast.md b/TODO_XMRvsBeast.md index 0731fb1..654a435 100644 --- a/TODO_XMRvsBeast.md +++ b/TODO_XMRvsBeast.md @@ -56,8 +56,11 @@ - [ ] optimizations - [x] benchmarks table render only what is visible - [x] console output render only what is visible - - [ ] migrate to hyper stable - [ ] use tor socks proxy instead of creating one + - [x] remove arti + - [ ] bundle arti cmd binary + - [ ] upgrade to hyper stable + - [ ] use hyper with socks proxy - [ ] better organize new code - [x] merge commits from upstream - [ ] tests for new functions diff --git a/src/app/mod.rs b/src/app/mod.rs index 5972025..81ac76e 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -230,12 +230,7 @@ impl App { must_resize: false, og: arc_mut!(State::new()), state: State::new(), - update: arc_mut!(Update::new( - String::new(), - PathBuf::new(), - PathBuf::new(), - true - )), + update: arc_mut!(Update::new(String::new(), PathBuf::new(), PathBuf::new(),)), file_window: FileWindow::new(), og_node_vec: Node::new_vec(), node_vec: Node::new_vec(), @@ -517,8 +512,7 @@ impl App { info!("App Init | Applying TOML values to [Update]..."); let p2pool_path = og.gupax.absolute_p2pool_path.clone(); let xmrig_path = og.gupax.absolute_xmrig_path.clone(); - let tor = og.gupax.update_via_tor; - app.update = arc_mut!(Update::new(app.exe.clone(), p2pool_path, xmrig_path, tor)); + app.update = arc_mut!(Update::new(app.exe.clone(), p2pool_path, xmrig_path)); // Set state version as compiled in version info!("App Init | Setting state Gupax version..."); diff --git a/src/app/panels/middle/gupax.rs b/src/app/panels/middle/gupax.rs index b659668..9212c14 100644 --- a/src/app/panels/middle/gupax.rs +++ b/src/app/panels/middle/gupax.rs @@ -86,12 +86,6 @@ impl Gupax { }; let size = vec2(width, height); ui.style_mut().override_text_style = Some(egui::TextStyle::Small); - ui.add_sized( - size, - Checkbox::new(&mut self.update_via_tor, "Update via Tor"), - ) - .on_hover_text(GUPAX_UPDATE_VIA_TOR); - ui.separator(); ui.add_sized(size, Checkbox::new(&mut self.auto_update, "Auto-Update")) .on_hover_text(GUPAX_AUTO_UPDATE); ui.separator(); diff --git a/src/components/update.rs b/src/components/update.rs index 2d58532..6edaf65 100644 --- a/src/components/update.rs +++ b/src/components/update.rs @@ -37,8 +37,6 @@ use crate::{ utils::errors::{ErrorButtons, ErrorFerris, ErrorState}, }; use anyhow::{anyhow, Error}; -use arti_client::TorClient; -use arti_hyper::*; use hyper::{ header::{HeaderValue, LOCATION}, Body, Client, Request, @@ -56,12 +54,12 @@ use walkdir::WalkDir; // tls implementation so this makes it fall back to the openssl variant. // // https://gitlab.torproject.org/tpo/core/arti/-/issues/715 -#[cfg(not(target_os = "macos"))] -use tls_api_native_tls::TlsConnector; -#[cfg(target_os = "macos")] -use tls_api_openssl::TlsConnector; +// #[cfg(not(target_os = "macos"))] +// use tls_api_native_tls::TlsConnector; +// #[cfg(target_os = "macos")] +// use tls_api_openssl::TlsConnector; -use tls_api::{TlsConnector as TlsConnectorTrait, TlsConnectorBuilder}; +// use tls_api::{TlsConnector as TlsConnectorTrait, TlsConnectorBuilder}; #[cfg(target_os = "windows")] use zip::ZipArchive; @@ -210,7 +208,7 @@ const FAKE_USER_AGENT: [&str; 25] = [ const MSG_NONE: &str = "No update in progress"; const MSG_START: &str = "Starting update"; const MSG_TMP: &str = "Creating temporary directory"; -const MSG_TOR: &str = "Creating Tor+HTTPS client"; +// const MSG_TOR: &str = "Creating Tor+HTTPS client"; const MSG_HTTPS: &str = "Creating HTTPS client"; const MSG_METADATA: &str = "Fetching package metadata"; const MSG_METADATA_RETRY: &str = "Fetching package metadata failed, attempt"; @@ -290,12 +288,11 @@ pub struct Update { pub updating: Arc>, // Is an update in progress? pub prog: Arc>, // Holds the 0-100% progress bar number pub msg: Arc>, // Message to display on [Gupax] tab while updating - pub tor: bool, // Is Tor enabled or not? } impl Update { // Takes in current paths from [State] - pub fn new(path_gupax: String, path_p2pool: PathBuf, path_xmrig: PathBuf, tor: bool) -> Self { + pub fn new(path_gupax: String, path_p2pool: PathBuf, path_xmrig: PathBuf) -> Self { Self { path_gupax, path_p2pool: path_p2pool.display().to_string(), @@ -304,7 +301,6 @@ impl Update { updating: arc_mut!(false), prog: arc_mut!(0.0), msg: arc_mut!(MSG_NONE.to_string()), - tor, } } @@ -342,26 +338,11 @@ impl Update { // ClientEnum::Tor(T) => get_response(... T ...) // ClientEnum::Https(H) => get_response(... H ...) // - pub fn get_client(tor: bool) -> Result { - if tor { - // Below is async, bootstraps immediately but has issues when recreating the circuit - // let tor = TorClient::create_bootstrapped(TorClientConfig::default()).await?; - // This one below is non-async, and doesn't bootstrap immediately. - let tor = TorClient::builder() - .bootstrap_behavior(arti_client::BootstrapBehavior::OnDemand) - .create_unbootstrapped()?; - // This makes sure the Tor circuit is different each time - let tor = TorClient::isolated_client(&tor); - let tls = TlsConnector::builder()?.build()?; - let connector = ArtiHttpConnector::new(tor, tls); - let client = ClientEnum::Tor(Client::builder().build(connector)); - Ok(client) - } else { - let mut connector = hyper_tls::HttpsConnector::new(); - connector.https_only(true); - let client = ClientEnum::Https(Client::builder().build(connector)); - Ok(client) - } + pub fn get_client() -> Result { + let mut connector = hyper_tls::HttpsConnector::new(); + connector.https_only(true); + let client = ClientEnum::Https(Client::builder().build(connector)); + Ok(client) } #[cold] @@ -486,7 +467,6 @@ impl Update { lock!(update).path_p2pool = p2pool_path.display().to_string(); lock!(update).path_xmrig = xmrig_path.display().to_string(); - lock!(update).tor = gupax.update_via_tor; // Clone before thread spawn let og = Arc::clone(og); @@ -570,18 +550,11 @@ impl Update { // Create Tor/HTTPS client let lock = lock!(update); - let tor = lock.tor; - if tor { - let msg = MSG_TOR.to_string(); - info!("Update | {}", msg); - *lock!(lock.msg) = msg; - } else { - let msg = MSG_HTTPS.to_string(); - info!("Update | {}", msg); - *lock!(lock.msg) = msg; - } + let msg = MSG_HTTPS.to_string(); + info!("Update | {}", msg); + *lock!(lock.msg) = msg; drop(lock); - let mut client = Self::get_client(tor)?; + let client = Self::get_client()?; *lock2!(update, prog) += 5.0; info!("Update | Init ... OK ... {}%", lock2!(update, prog)); @@ -613,7 +586,6 @@ impl Update { // Send to async let handle: JoinHandle> = tokio::spawn(async move { match client { - ClientEnum::Tor(t) => Pkg::get_metadata(new_ver, t, link, user_agent).await, ClientEnum::Https(h) => { Pkg::get_metadata(new_ver, h, link, user_agent).await } @@ -654,10 +626,6 @@ impl Update { } // Some Tor exit nodes seem to be blocked by GitHub's API, // so recreate the circuit every loop. - if tor { - info!("Update | Recreating Tor client..."); - client = Self::get_client(tor)?; - } } if vec.is_empty() { info!("Update | Metadata ... OK ... {}%", lock2!(update, prog)); @@ -761,7 +729,6 @@ impl Update { info!("Update | {} ... {}", pkg.name, link); let handle: JoinHandle> = tokio::spawn(async move { match client { - ClientEnum::Tor(t) => Pkg::get_bytes(bytes, t, link, user_agent).await, ClientEnum::Https(h) => Pkg::get_bytes(bytes, h, link, user_agent).await, } }); @@ -942,7 +909,6 @@ impl Update { #[derive(Debug, Clone)] pub enum ClientEnum { - Tor(hyper::Client>), Https(hyper::Client>), } diff --git a/src/disk/state.rs b/src/disk/state.rs index 4692855..b48fa63 100644 --- a/src/disk/state.rs +++ b/src/disk/state.rs @@ -182,7 +182,6 @@ pub struct Gupax { // pub auto_monero: bool, pub ask_before_quit: bool, pub save_before_quit: bool, - pub update_via_tor: bool, pub p2pool_path: String, pub xmrig_path: String, pub absolute_p2pool_path: PathBuf, @@ -280,7 +279,6 @@ impl Default for Gupax { auto_xvb: true, ask_before_quit: true, save_before_quit: true, - update_via_tor: true, p2pool_path: DEFAULT_P2POOL_PATH.to_string(), xmrig_path: DEFAULT_XMRIG_PATH.to_string(), absolute_p2pool_path: into_absolute_path(DEFAULT_P2POOL_PATH.to_string()).unwrap(), diff --git a/src/disk/tests.rs b/src/disk/tests.rs index 66fabeb..a987b7f 100644 --- a/src/disk/tests.rs +++ b/src/disk/tests.rs @@ -34,7 +34,6 @@ mod test { auto_xvb = false ask_before_quit = true save_before_quit = true - update_via_tor = true p2pool_path = "p2pool/p2pool" xmrig_path = "xmrig/xmrig" absolute_p2pool_path = "/home/hinto/p2pool/p2pool" @@ -168,7 +167,6 @@ mod test { auto_xmrig = false ask_before_quit = true save_before_quit = true - update_via_tor = true p2pool_path = "p2pool/p2pool" xmrig_path = "xmrig/xmrig" absolute_p2pool_path = "" diff --git a/src/utils/constants.rs b/src/utils/constants.rs index e6a8b15..2563cd7 100644 --- a/src/utils/constants.rs +++ b/src/utils/constants.rs @@ -265,10 +265,10 @@ pub const GUPAX_UPDATE: &str = pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup"; pub const GUPAX_SHOULD_RESTART: &str = "Gupax was updated. A restart is recommended but not required"; -#[cfg(not(target_os = "macos"))] -pub const GUPAX_UPDATE_VIA_TOR: &str = "Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required"; -#[cfg(target_os = "macos")] // Arti library has issues on macOS -pub const GUPAX_UPDATE_VIA_TOR: &str = "WARNING: This option is unstable on macOS. Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required"; +// #[cfg(not(target_os = "macos"))] +// pub const GUPAX_UPDATE_VIA_TOR: &str = "Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required"; +// #[cfg(target_os = "macos")] // Arti library has issues on macOS +// pub const GUPAX_UPDATE_VIA_TOR: &str = "WARNING: This option is unstable on macOS. Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required"; pub const GUPAX_ASK_BEFORE_QUIT: &str = "Ask before quitting Gupax"; pub const GUPAX_SAVE_BEFORE_QUIT: &str = "Automatically save any changed settings before quitting"; pub const GUPAX_AUTO_P2POOL: &str = "Automatically start P2Pool on Gupax startup. If you are using [P2Pool Simple], this will NOT wait for your [Auto-Ping] to finish, it will start P2Pool on the pool you already have selected. This option will fail if your P2Pool settings aren't valid!"; @@ -334,7 +334,7 @@ You may encounter connection issues with remote nodes which may cause mining per Running and using your own local Monero node improves privacy and ensures your connection is as stable as your own internet connection. This comes at the cost of downloading and syncing Monero's blockchain yourself (currently 170GB). If you have the disk space, consider using the [Advanced] tab and connecting to your own Monero node. -For a simple guide, see the [Running a Local Monero Node] section on Gupax's GitHub by clicking this message."#; +For a simple guide, see the [Running a Local Monero Node] section on Gupax s GitHub by clicking this message."#; pub const P2POOL_INPUT: &str = "Send a command to P2Pool"; pub const P2POOL_ARGUMENTS: &str = r#"WARNING: Use [--no-color] and make sure to set [--data-api ] & [--local-api] so that the [Status] tab can work! @@ -417,8 +417,11 @@ pub const XVB_NODE_RPC: &str = "18089"; pub const XVB_URL_RULES: &str = "https://xmrvsbeast.com/p2pool/rules.html"; // buffer in percentage of HR to have plus the requirement. pub const XVB_BUFFER: f32 = 1.05; -// time in second the algorithm will distribute the HR +// time in second the algorithm will distribute the HR, 10 minutes for release and 30 seconds for debug. +#[cfg(not(debug_assertions))] pub const XVB_TIME_ALGO: u32 = 600; +#[cfg(debug_assertions)] +pub const XVB_TIME_ALGO: u32 = 60; pub const XVB_TOKEN_LEN: usize = 9; pub const XVB_HERO_SELECT: &str = "This mode will donate all available hashrate while keeping a share in the p2pool PPLNS window"; @@ -453,7 +456,7 @@ the environment variable [RUST_LOG] set to a log level like so: RUST_LOG=(trace|debug|info|warn|error) ./gupax"#; pub const ARG_COPYRIGHT: &str = r#"Gupax is licensed under GPLv3. For more information, see link below: -"#; +"#; // Unknown Data, replace HumanNumlber::unknown() pub const UNKNOWN_DATA: &str = "???";