From 12c1f67baaa2338c8b6ac6eaf1a736a8c73513de Mon Sep 17 00:00:00 2001 From: hinto-janaiyo <hinto.janaiyo@protonmail.com> Date: Mon, 21 Nov 2022 17:16:31 -0500 Subject: [PATCH] cargo/tor/p2pool: clean deps, warn macos arti, fix node overflow Cargo: Cleanup unused dependencies, enable some build optimizations Tor: Arti doesn't seem to work on macOS Even a bare Arti+Hyper request doesn't seem to work, so it's probably not something to do with Gupax. A lot of issues only seem to popup in a VM (OpenGL, TLS) even though on bare metal Gupax runs fine, so Tor might work fine on real macOS but I don't have real macOS to test it. VM macOS can't create a circuit, so, disable by default and add a warning that it's unstable. P2Pool: Let selected_index start at 0, and only +1 when printing to the user, this makes the overflow math when adding/deleting a lot more simple because selected_index will match the actual index of the node vector --- Cargo.lock | 328 +++++++---------------------------------------- Cargo.toml | 25 ++-- src/constants.rs | 3 + src/disk.rs | 18 +-- src/main.rs | 10 +- src/node.rs | 3 +- src/p2pool.rs | 36 ++++-- src/update.rs | 8 +- 8 files changed, 100 insertions(+), 331 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ef473c..da3d737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,15 +89,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anyhow" version = "1.0.66" @@ -322,15 +313,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base58-monero" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d079cdf47e1ca75554200bb2f30bff5a5af16964cac4a566b18de9a5d48db2b" -dependencies = [ - "thiserror", -] - [[package]] name = "base64" version = "0.13.1" @@ -430,9 +412,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] name = "bzip2" @@ -486,9 +468,9 @@ checksum = "ceea694ffdf0118d2df95ace6fd9edfc6d27f88408d0d73b390f2d9e5699b3f2" [[package]] name = "cc" -version = "1.0.76" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" dependencies = [ "jobserver", ] @@ -523,21 +505,6 @@ dependencies = [ "libc", ] -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "time 0.1.44", - "wasm-bindgen", - "winapi", -] - [[package]] name = "cipher" version = "0.3.0" @@ -621,16 +588,6 @@ dependencies = [ "objc", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "color_quant" version = "1.1.0" @@ -773,22 +730,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" +checksum = "96bf8df95e795db1a4aca2957ad884a2df35413b24bbeb3114422f3cc21498e8" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.7.1", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "ebb3d1683412e9be6a15533314f00ec223c0762c522a3f77f048b265aab4470c" dependencies = [ "cfg-if", "crossbeam-utils", @@ -796,9 +753,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +checksum = "422f23e724af1240ec469ea1e834d87a4b59ce2efe2c6a96256b0c47e2fd86aa" dependencies = [ "cfg-if", ] @@ -880,50 +837,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "cxx" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97abf9f0eca9e52b7f81b945524e76710e6cb2366aead23b7d4fbf72e281f888" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc32cc5fea1d894b77d269ddb9f192110069a8a9c1f1d441195fba90553dea3" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca220e4794c934dc6b1207c3b42856ad4c302f2df1712e9f8d2eec5afaacf1f" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b846f081361125bfc8dc9d3940c84e1fd83ba54bbca7b17cd29483c828be0704" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "darling" version = "0.13.4" @@ -1254,7 +1167,7 @@ dependencies = [ "bytemuck", "egui", "glow", - "memoffset", + "memoffset 0.6.5", "tracing", "wasm-bindgen", "web-sys", @@ -1417,18 +1330,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "fixed-hash" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand 0.8.5", - "rustc-hex", - "static_assertions", -] - [[package]] name = "flate2" version = "1.0.24" @@ -1892,7 +1793,6 @@ dependencies = [ "arti-client", "arti-hyper", "bytes", - "chrono", "dirs", "eframe", "egui", @@ -1900,22 +1800,17 @@ dependencies = [ "env_logger 0.9.3", "figment", "flate2", - "hex-literal", "hyper", "hyper-tls", "image", "log", - "monero", "num-format", "num_cpus", - "openssl", "rand 0.8.5", "regex", "rfd", - "rusqlite", "serde", "serde_json", - "sha2 0.10.6", "tar", "tls-api", "tls-api-native-tls", @@ -1954,15 +1849,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.0" @@ -1984,12 +1870,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - [[package]] name = "hkdf" version = "0.12.3" @@ -2103,30 +1983,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -2164,9 +2020,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", "hashbrown", @@ -2318,15 +2174,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "link-cplusplus" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] - [[package]] name = "lock_api" version = "0.4.9" @@ -2390,6 +2237,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "merlin" version = "2.0.1" @@ -2438,22 +2294,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "monero" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de5ecaeeb7618bb1554d1d90e79cc673ba755fd20d43ed4352ab6efa1a7b0f" -dependencies = [ - "base58-monero", - "curve25519-dalek", - "fixed-hash", - "hex", - "hex-literal", - "sealed", - "thiserror", - "tiny-keccak", -] - [[package]] name = "nanorand" version = "0.7.0" @@ -2502,7 +2342,7 @@ checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" dependencies = [ "bitflags", "jni-sys", - "ndk-sys 0.4.0", + "ndk-sys 0.4.0+25.0.8775105", "num_enum", "raw-window-handle 0.5.0", "thiserror", @@ -2540,7 +2380,7 @@ dependencies = [ "ndk 0.7.0", "ndk-context", "ndk-macro", - "ndk-sys 0.4.0", + "ndk-sys 0.4.0+25.0.8775105", "once_cell", "parking_lot", ] @@ -2569,9 +2409,9 @@ dependencies = [ [[package]] name = "ndk-sys" -version = "0.4.0" +version = "0.4.0+25.0.8775105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046" +checksum = "f74ddd54b7da8d38d399faf43472ac9759f1a028a45c83154bff603e0f56385a" dependencies = [ "jni-sys", ] @@ -2586,7 +2426,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] @@ -2598,7 +2438,7 @@ dependencies = [ "bitflags", "cfg-if", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] @@ -2611,7 +2451,7 @@ dependencies = [ "bitflags", "cfg-if", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] @@ -2643,9 +2483,9 @@ dependencies = [ [[package]] name = "num-bigint-dig" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566d173b2f9406afbc5510a90925d5a2cd80cae4605631f1212303df265de011" +checksum = "2399c9463abc5f909349d8aa9ba080e0b88b3ce2885389b60b993f39b1a56905" dependencies = [ "byteorder", "lazy_static", @@ -3229,11 +3069,10 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "1e060280438193c554f654141c9ea9417886713b7acd75974c85b18a69a88e0b" dependencies = [ - "autocfg", "crossbeam-deque", "either", "rayon-core", @@ -3241,9 +3080,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -3380,7 +3219,7 @@ dependencies = [ "hashlink", "libsqlite3-sys", "smallvec", - "time 0.3.17", + "time", ] [[package]] @@ -3389,12 +3228,6 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - [[package]] name = "rustc_version" version = "0.4.0" @@ -3483,12 +3316,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "sctk-adwaita" version = "0.4.3" @@ -3501,18 +3328,6 @@ dependencies = [ "tiny-skia", ] -[[package]] -name = "sealed" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5e421024b5e5edfbaa8e60ecf90bda9dbffc602dbb230e6028763f85f0c68c" -dependencies = [ - "heck 0.3.3", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "security-framework" version = "2.7.0" @@ -3573,9 +3388,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7" dependencies = [ "itoa", "ryu", @@ -3700,15 +3515,6 @@ dependencies = [ "dirs", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" -dependencies = [ - "libc", -] - [[package]] name = "signature" version = "1.6.4" @@ -3724,7 +3530,7 @@ dependencies = [ "num-bigint", "num-traits", "thiserror", - "time 0.3.17", + "time", ] [[package]] @@ -3854,7 +3660,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -3897,7 +3703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2955b1fe31e1fa2fbd1976b71cc69a606d7d4da16f6de3333d0c92d51419aeff" dependencies = [ "cfg-expr", - "heck 0.4.0", + "heck", "pkg-config", "toml", "version-compare", @@ -3988,17 +3794,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.3.17" @@ -4026,15 +3821,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - [[package]] name = "tiny-skia" version = "0.7.0" @@ -4133,9 +3919,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.21.2" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" dependencies = [ "autocfg", "bytes", @@ -4143,9 +3929,7 @@ dependencies = [ "memchr", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", "tokio-macros", "winapi", @@ -4444,7 +4228,7 @@ dependencies = [ "serde", "signature", "thiserror", - "time 0.3.17", + "time", "tor-basic-utils", "tor-checkable", "tor-circmgr", @@ -4601,7 +4385,7 @@ dependencies = [ "serde_with", "signature", "thiserror", - "time 0.3.17", + "time", "tinystr", "tor-bytes", "tor-cert", @@ -4810,18 +4594,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -4918,12 +4690,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -5469,7 +5235,7 @@ dependencies = [ "hmac", "pbkdf2", "sha1", - "time 0.3.17", + "time", "zstd", ] diff --git a/Cargo.toml b/Cargo.toml index 891132c..13644d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,17 @@ description = "GUI for P2Pool+XMRig" documentation = "https://github.com/hinto-janaiyo/gupax" edition = "2021" +[profile.release] +debug = false +strip = "symbols" +codegen-units = 1 +lto = true + [dependencies] anyhow = "1.0.65" -arti-client = "0.7.0" +arti-client = { version = "0.7.0", features = ["static"] } arti-hyper = "0.7.0" bytes = "1.2.1" -chrono = "0.4.22" dirs = "4.0.0" eframe = "0.19.0" egui = "0.19.0" @@ -27,27 +32,20 @@ egui_extras = { version = "0.19.0", features = ["image"] } #egui_extras = { path = "external/egui/crates/egui_extras", features = ["image"] } env_logger = "0.9.1" figment = { version = "0.10.8", features = ["toml"] } -flate2 = "1.0" -hex-literal = "0.3.4" hyper = "0.14.20" -#hyper = { version = "0.14.20", features = ["full"] } hyper-tls = "0.5.0" image = { version = "0.24.4", features = ["png"] } log = "0.4.17" -monero = "0.18.0" num_cpus = "1.13.1" num-format = "0.4.0" rand = "0.8.5" -regex = "1.6.0" -#reqwest = { version = "0.11.12", features = ["blocking", "json"] } +regex = { version = "1.6.0", default-features = false, features = ["perf"] } rfd = "0.10.0" -rusqlite = { version = "0.28.0", features = ["bundled"] } serde = { version = "1.0.145", features = ["rc", "derive"] } serde_json = "1.0" -sha2 = "0.10.6" tls-api = "0.9.0" tls-api-native-tls = "0.9.0" -tokio = { version = "1.21.2", features = ["full"] } +tokio = { version = "1.21.2", features = ["rt", "time", "macros"] } toml = { version = "0.5.9", features = ["preserve_order"] } tor-rtcompat = "0.7.0" walkdir = "2.3.2" @@ -55,10 +53,7 @@ walkdir = "2.3.2" # Unix dependencies [target.'cfg(unix)'.dependencies] tar = "0.4.38" - -# Bundle OpenSSL for Linux -[target.'cfg(linux)'.dependencies] -openssl = { version = "*", features = ["vendored"] } +flate2 = "1.0" # Windows dependencies [target.'cfg(windows)'.dependencies] diff --git a/src/constants.rs b/src/constants.rs index c21250d..211a2bb 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -56,7 +56,10 @@ pub const OS_NAME: &'static str = "Linux"; // Gupax pub const GUPAX_UPDATE: &'static str = "Check for updates on Gupax, P2Pool, and XMRig via GitHub's API and upgrade automatically"; pub const GUPAX_AUTO_UPDATE: &'static str = "Automatically check for updates at startup"; +#[cfg(not(target_os = "macos"))] pub const GUPAX_UPDATE_VIA_TOR: &'static 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: &'static 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: &'static str = "Ask before quitting Gupax"; pub const GUPAX_SAVE_BEFORE_QUIT: &'static str = "Automatically save any changed settings before quitting"; pub const GUPAX_SELECT: &'static str = "Open a file explorer to select a file"; diff --git a/src/disk.rs b/src/disk.rs index 44f70bb..c1cffbb 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -120,7 +120,10 @@ impl State { auto_node: true, ask_before_quit: true, save_before_quit: true, + #[cfg(not(target_os = "macos"))] update_via_tor: true, + #[cfg(target_os = "macos")] // Arti library has issues on macOS + update_via_tor: false, 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(), @@ -141,7 +144,7 @@ impl State { ip: "localhost".to_string(), rpc: "18081".to_string(), zmq: "18083".to_string(), - selected_index: 1, + selected_index: 0, selected_name: "Local Monero Node".to_string(), selected_ip: "localhost".to_string(), selected_rpc: "18081".to_string(), @@ -204,7 +207,7 @@ impl State { // Deserialize, attempt merge if failed match Self::from_string(&string) { Ok(s) => Ok(s), - Err(e) => { + Err(_) => { warn!("State | Attempting merge..."); Self::merge(string, path) }, @@ -442,15 +445,6 @@ pub enum File { Node, } -impl File { - fn name(&self) -> &'static str { - match *self { - Self::State => "state.toml", - Self::Node => "node.toml", - } - } -} - //---------------------------------------------------------------------------------------------------- [Node] Struct #[derive(Clone,Eq,PartialEq,Debug,Deserialize,Serialize)] pub struct Node { @@ -497,7 +491,7 @@ pub struct P2pool { pub ip: String, pub rpc: String, pub zmq: String, - pub selected_index: u16, + pub selected_index: usize, pub selected_name: String, pub selected_ip: String, pub selected_rpc: String, diff --git a/src/main.rs b/src/main.rs index 76864f5..924c0f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,10 +38,10 @@ use regex::Regex; // std use std::{ + env, io::Write, process::exit, sync::{Arc,Mutex}, - {thread,env}, time::Instant, path::PathBuf, }; @@ -219,15 +219,15 @@ impl App { og.xmrig.current_threads = max; } // Handle [node_vec] overflow - if og.p2pool.selected_index > app.og_node_vec.len() as u16 { + if og.p2pool.selected_index > app.og_node_vec.len() { warn!("App | Overflowing manual node index [{} > {}], resetting to 1", og.p2pool.selected_index, app.og_node_vec.len()); let (name, node) = app.og_node_vec[0].clone(); - og.p2pool.selected_index = 1; + og.p2pool.selected_index = 0; og.p2pool.selected_name = name.clone(); og.p2pool.selected_ip = node.ip.clone(); og.p2pool.selected_rpc = node.rpc.clone(); - og.p2pool.selected_zmq = node.rpc.clone(); - app.state.p2pool.selected_index = 1; + og.p2pool.selected_zmq = node.zmq.clone(); + app.state.p2pool.selected_index = 0; app.state.p2pool.selected_name = name; app.state.p2pool.selected_ip = node.ip; app.state.p2pool.selected_rpc = node.rpc; diff --git a/src/node.rs b/src/node.rs index 6e2f165..460c689 100644 --- a/src/node.rs +++ b/src/node.rs @@ -24,7 +24,6 @@ use log::*; use hyper::{ client::HttpConnector, Client,Body,Request, - header::{HeaderValue,LOCATION}, }; //---------------------------------------------------------------------------------------------------- Node list @@ -293,7 +292,7 @@ impl Ping { info = format!("{}ms ... {}: {}", ms, id, ip); info!("Ping | {}", info) }, - Err(e) => { + Err(_) => { ms = 5000; info = format!("{}ms ... {}: {}", ms, id, ip); warn!("Ping | {}", info) diff --git a/src/p2pool.rs b/src/p2pool.rs index a72bd92..22391ac 100644 --- a/src/p2pool.rs +++ b/src/p2pool.rs @@ -276,11 +276,11 @@ impl P2pool { ui.spacing_mut().slider_width = width - 8.0; ui.spacing_mut().icon_width = width / 25.0; // [Ping List] - let text = RichText::new(format!("{}. {}", self.selected_index, self.selected_name)); + let text = RichText::new(format!("{}. {}", self.selected_index+1, self.selected_name)); ComboBox::from_id_source("manual_nodes").selected_text(RichText::text_style(text, Monospace)).show_ui(ui, |ui| { - let mut n = 1; + let mut n = 0; for (name, node) in node_vec.iter() { - let text = RichText::text_style(RichText::new(format!("{}. {}\n IP: {}\n RPC: {}\n ZMQ: {}", n, name, node.ip, node.rpc, node.zmq)), Monospace); + let text = RichText::text_style(RichText::new(format!("{}. {}\n IP: {}\n RPC: {}\n ZMQ: {}", n+1, name, node.ip, node.rpc, node.zmq)), Monospace); if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() { self.selected_index = n; let node = node.clone(); @@ -314,7 +314,7 @@ impl P2pool { ui.horizontal(|ui| { let text; if exists { text = P2POOL_SAVE } else { text = P2POOL_ADD } - let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", text, self.selected_index, self.selected_name, node_vec_len); + let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", text, self.selected_index+1, self.selected_name, node_vec_len); // If the node already exists, show [Save] and mutate the already existing node if exists { ui.set_enabled(!incorrect_input && save_diff); @@ -324,7 +324,7 @@ impl P2pool { rpc: self.rpc.clone(), zmq: self.zmq.clone(), }; - node_vec[existing_index as usize].1 = node; + node_vec[existing_index].1 = node; info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", existing_index+1, self.name, self.ip, self.rpc, self.zmq); } // Else, add to the list @@ -337,24 +337,35 @@ impl P2pool { zmq: self.zmq.clone(), }; node_vec.push((self.name.clone(), node)); - self.selected_index = (node_vec_len+1) as u16; + self.selected_index = (node_vec_len); self.selected_name = self.name.clone(); self.selected_ip = self.ip.clone(); self.selected_rpc = self.rpc.clone(); self.selected_zmq = self.zmq.clone(); - info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", node_vec_len+1, self.name, self.ip, self.rpc, self.zmq); + info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", node_vec_len, self.name, self.ip, self.rpc, self.zmq); } } }); // [Delete] ui.horizontal(|ui| { ui.set_enabled(node_vec_len > 1); - let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", P2POOL_DELETE, self.selected_index, self.selected_name, node_vec_len); + let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", P2POOL_DELETE, self.selected_index+1, self.selected_name, node_vec_len); if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() { - let new_index = self.selected_index-1; - let new_name = node_vec[(new_index-1) as usize].0.clone(); - let new_node = node_vec[(new_index-1) as usize].1.clone(); - self.selected_index = new_index; + let new_name; + let new_node; + match self.selected_index { + 0 => { + new_name = node_vec[1].0.clone(); + new_node = node_vec[1].1.clone(); + node_vec.remove(0); + } + _ => { + node_vec.remove(self.selected_index); + self.selected_index = self.selected_index-1; + new_name = node_vec[self.selected_index].0.clone(); + new_node = node_vec[self.selected_index].1.clone(); + } + }; self.selected_name = new_name.clone(); self.selected_ip = new_node.ip.clone(); self.selected_rpc = new_node.rpc.clone(); @@ -363,7 +374,6 @@ impl P2pool { self.ip = new_node.ip; self.rpc = new_node.rpc; self.zmq = new_node.zmq; - node_vec.remove(self.selected_index as usize); info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", self.selected_index, self.selected_name, self.selected_ip, self.selected_rpc, self.selected_zmq); } }); diff --git a/src/update.rs b/src/update.rs index 52e539f..bf7345a 100644 --- a/src/update.rs +++ b/src/update.rs @@ -228,10 +228,12 @@ impl Update { // pub fn get_client(tor: bool) -> Result<ClientEnum, anyhow::Error> { 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()?; - // Below is async, bootstraps immediately but has issues when recreating the circuit -// let tor = TorClient::create_bootstrapped(TorClientConfig::default()).await?; + // This makes sure the Tor circuit is different each time + let tor = TorClient::isolated_client(&tor); let tls = tls_api_native_tls::TlsConnector::builder()?.build()?; let connector = ArtiHttpConnector::new(tor, tls); let client = ClientEnum::Tor(Client::builder().build(connector)); @@ -375,7 +377,7 @@ impl Update { let mut indexes = vec![]; for (index, pkg) in vec.iter().enumerate() { if pkg.new_ver.lock().unwrap().is_empty() { - warn!("Update | {} failed, attempt [{}/3]...", pkg.name, i); + warn!("Update | {} failed, attempt [{}/3]...", pkg.name, i+1); } else { indexes.push(index); vec2.push(pkg.clone());