mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-17 09:47:36 +00:00
update: be more lenient on new binary filename match
Instead of a single "true" filename when walking dirs searching for the newly downloaded (Gupax|P2Pool|XMRig), allow for multiple valid names as long as they _seem_ correct AND are files, e.g: GUPAX|Gupax|gupax (.exe) P2POOL|P2Pool|P2pool|p2pool (.exe) XMRIG|XMRig|Xmrig|xmrig (.exe) If the packaging naming schemes change for any of these, the update code will be able to actually handle it.
This commit is contained in:
parent
3717ab3b23
commit
4cac807ca7
4 changed files with 94 additions and 32 deletions
|
@ -552,7 +552,7 @@ The latest versions are downloaded using the GitHub API.
|
||||||
* P2Pool [`https://github.com/SChernykh/p2pool`](https://github.com/SChernykh/p2pool)
|
* P2Pool [`https://github.com/SChernykh/p2pool`](https://github.com/SChernykh/p2pool)
|
||||||
* XMRig [`https://github.com/xmrig/xmrig`](https://github.com/xmrig/xmrig)
|
* XMRig [`https://github.com/xmrig/xmrig`](https://github.com/xmrig/xmrig)
|
||||||
|
|
||||||
GitHub's API blocks request that do not have an HTTP `User-Agent` header. [Gupax uses a random recent version of a `Wget/Curl` user-agent.](https://github.com/hinto-janaiyo/gupax/blob/2b80aa027728ddd193bac2e77caa5ddb4323f8fd/src/update.rs#L134)
|
GitHub's API blocks request that do not have an HTTP `User-Agent` header. [Gupax uses a random recent version of a `Wget/Curl` user-agent.](https://github.com/hinto-janaiyo/gupax/blob/e6bf49b309c64d29e50c0a1a185fcf0ebc05e7c7/src/update.rs#L134)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ Although Gupax uses a temporary folder (`gupax_update_[A-Za-z0-9]`) to store tem
|
||||||
### How much memory does Gupax use?
|
### How much memory does Gupax use?
|
||||||
Gupax itself uses around 100-300 megabytes of memory.
|
Gupax itself uses around 100-300 megabytes of memory.
|
||||||
|
|
||||||
Gupax also holds up to [500,000 bytes](https://github.com/hinto-janaiyo/gupax/blob/2b80aa027728ddd193bac2e77caa5ddb4323f8fd/src/helper.rs#L63) of log data from `P2Pool/XMRig` to display in the GUI terminals. These logs are reset once over capacity which takes around 1-4 hours.
|
Gupax also holds up to [500,000 bytes](https://github.com/hinto-janaiyo/gupax/blob/e6bf49b309c64d29e50c0a1a185fcf0ebc05e7c7/src/helper.rs#L59) of log data from `P2Pool/XMRig` to display in the GUI terminals. These logs are reset once over capacity which takes around 1-4 hours.
|
||||||
|
|
||||||
Memory usage should *never* be above 500~ megabytes. If you see Gupax using more than this, please send a bug report.
|
Memory usage should *never* be above 500~ megabytes. If you see Gupax using more than this, please send a bug report.
|
||||||
|
|
||||||
|
|
|
@ -78,26 +78,46 @@ Main [App] outer frame (default: [1280.0, 960.0], 4:3 aspect ratio)
|
||||||
This is the internal naming scheme used by Gupax when updating/creating default folders/etc:
|
This is the internal naming scheme used by Gupax when updating/creating default folders/etc:
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
- Gupax: `Gupax.exe`
|
```
|
||||||
- P2Pool: `P2Pool\p2pool.exe`
|
Gupax\
|
||||||
- XMRig: `XMRig\xmrig.exe`
|
├─ Gupax.exe
|
||||||
|
├─ P2Pool\
|
||||||
|
│ ├─ p2pool.exe
|
||||||
|
├─ XMRig\
|
||||||
|
├─ xmrig.exe
|
||||||
|
```
|
||||||
|
|
||||||
macOS:
|
macOS (Gupax is packaged as an `.app` on macOS):
|
||||||
- Gupax: `Gupax.app/Contents/MacOS/gupax` (Gupax is packaged as an `.app` on macOS)
|
```
|
||||||
- P2Pool: `p2pool/p2pool`
|
Gupax.app/Contents/MacOS/
|
||||||
- XMRig: `xmrig/xmrig`
|
├─ gupax
|
||||||
|
├─ p2pool/
|
||||||
|
│ ├─ p2pool
|
||||||
|
├─ xmrig/
|
||||||
|
├─ xmrig
|
||||||
|
```
|
||||||
|
|
||||||
Linux:
|
Linux:
|
||||||
- Gupax: `gupax`
|
```
|
||||||
- P2Pool: `p2pool/p2pool`
|
gupax/
|
||||||
- XMRig: `xmrig/xmrig`
|
├─ gupax
|
||||||
|
├─ p2pool/
|
||||||
|
│ ├─ p2pool
|
||||||
|
├─ xmrig/
|
||||||
|
├─ xmrig
|
||||||
|
```
|
||||||
|
|
||||||
These have to be packaged exactly with these names because the update code is case-sensitive. If an exact match is not found, it will error.
|
When Gupax updates, it walks the directories of the extracted `zip/tar` searching for a valid file. These are the valid filenames Gupax will match against and assume is the new binary we're looking for:
|
||||||
|
- `[GUPAX, Gupax, gupax]`
|
||||||
|
- `[P2POOL, P2Pool, P2pool, p2pool]`
|
||||||
|
- `[XMRIG, XMRig, Xmrig, xmrig]`
|
||||||
|
|
||||||
Package naming schemes:
|
Windows versions of Gupax also need the file to end with `.exe`.
|
||||||
- `gupax` - gupax-vX.X.X-(windows|macos|linux)-x64(standalone|bundle).(zip|tar.gz)
|
|
||||||
- `p2pool` - p2pool-vX.X.X-(windows|macos|linux)-x64.(zip|tar.gz)
|
The actual `zip/tar` matching is static, however. They have to be packaged exactly with the following naming scheme. If an exact match is not found, it will error:
|
||||||
- `xmrig` - xmrig-X.X.X-(msvc-win64|macos-x64|linux-static-x64).(zip|tar.gz)
|
- `gupax-vX.X.X-(windows|macos|linux)-x64-(bundle|standalone).(zip|tar.gz)`
|
||||||
|
- `p2pool-vX.X.X-(windows|macos|linux)-x64.(zip|tar.gz)`
|
||||||
|
- `xmrig-X.X.X-(msvc-win64|macos-x64|linux-static-x64).(zip|tar.gz)`
|
||||||
|
|
||||||
Exceptions (there are always exceptions...):
|
Exceptions (there are always exceptions...):
|
||||||
- XMRig doesn't have a [v], so it is [xmrig-6.18.0-...]
|
- XMRig doesn't have a [v], so it is [xmrig-6.18.0-...]
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct Status {}
|
||||||
impl Status {
|
impl Status {
|
||||||
pub fn show(sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolApi>>, xmrig_api: &Arc<Mutex<PubXmrigApi>>, p2pool_img: &Arc<Mutex<ImgP2pool>>, xmrig_img: &Arc<Mutex<ImgXmrig>>, p2pool_alive: bool, xmrig_alive: bool, max_threads: usize, width: f32, height: f32, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
pub fn show(sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolApi>>, xmrig_api: &Arc<Mutex<PubXmrigApi>>, p2pool_img: &Arc<Mutex<ImgP2pool>>, xmrig_img: &Arc<Mutex<ImgXmrig>>, p2pool_alive: bool, xmrig_alive: bool, max_threads: usize, width: f32, height: f32, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||||
let width = (width/3.0)-(SPACE*1.666);
|
let width = (width/3.0)-(SPACE*1.666);
|
||||||
let min_height = height/1.14;
|
let min_height = height/1.1;
|
||||||
let height = height/25.0;
|
let height = height/25.0;
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
// [Gupax]
|
// [Gupax]
|
||||||
|
|
|
@ -119,20 +119,60 @@ const XMRIG_BINARY: &str = "xmrig.exe";
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
const XMRIG_BINARY: &str = "xmrig";
|
const XMRIG_BINARY: &str = "xmrig";
|
||||||
|
|
||||||
|
// --- Valid Windows Gupax
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const ACCEPTABLE_GUPAX: [&str; 3] = ["GUPAX.exe", "Gupax.exe", "gupax.exe"];
|
pub mod valid_gupax {
|
||||||
|
pub const VALID_GUPAX_1: &str = "GUPAX.exe";
|
||||||
|
pub const VALID_GUPAX_2: &str = "Gupax.exe";
|
||||||
|
pub const VALID_GUPAX_3: &str = "gupax.exe";
|
||||||
|
}
|
||||||
|
// --- Valid Unix Gupax
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
const ACCEPTABLE_GUPAX: [&str; 3] = ["GUPAX", "Gupax", "gupax"];
|
pub mod valid_gupax {
|
||||||
|
pub const VALID_GUPAX_1: &str = "GUPAX";
|
||||||
|
pub const VALID_GUPAX_2: &str = "Gupax";
|
||||||
|
pub const VALID_GUPAX_3: &str = "gupax";
|
||||||
|
}
|
||||||
|
use crate::valid_gupax::*;
|
||||||
|
const VALID_GUPAX: [&str; 3] = [VALID_GUPAX_1, VALID_GUPAX_2, VALID_GUPAX_3];
|
||||||
|
|
||||||
|
// --- Valid Windows XMRig
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const ACCEPTABLE_XMRIG: [&str; 4] = ["XMRIG.exe", "XMRig.exe", "Xmrig.exe", "xmrig.exe"];
|
pub mod valid_xmrig {
|
||||||
|
pub const VALID_XMRIG_1: &str = "XMRIG.exe";
|
||||||
|
pub const VALID_XMRIG_2: &str = "XMRig.exe";
|
||||||
|
pub const VALID_XMRIG_3: &str = "Xmrig.exe";
|
||||||
|
pub const VALID_XMRIG_4: &str = "xmrig.exe";
|
||||||
|
}
|
||||||
|
// --- Valid Unix XMRig
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
const ACCEPTABLE_XMRIG: [&str; 4] = ["XMRIG", "XMRig", "Xmrig", "xmrig"];
|
pub mod valid_xmrig {
|
||||||
|
pub const VALID_XMRIG_1: &str = "XMRIG";
|
||||||
|
pub const VALID_XMRIG_2: &str = "XMRig";
|
||||||
|
pub const VALID_XMRIG_3: &str = "Xmrig";
|
||||||
|
pub const VALID_XMRIG_4: &str = "xmrig";
|
||||||
|
}
|
||||||
|
use crate::valid_xmrig::*;
|
||||||
|
const VALID_XMRIG: [&str; 4] = [VALID_XMRIG_1, VALID_XMRIG_2, VALID_XMRIG_3, VALID_XMRIG_4];
|
||||||
|
|
||||||
|
// --- Valid Windows P2Pool
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const ACCEPTABLE_P2POOL: [&str; 4] = ["P2POOL.exe", "P2Pool.exe", "P2pool.exe", "p2pool.exe"];
|
pub mod valid_p2pool {
|
||||||
|
pub const VALID_P2POOL_1: &str = "P2POOL.exe";
|
||||||
|
pub const VALID_P2POOL_2: &str = "P2Pool.exe";
|
||||||
|
pub const VALID_P2POOL_3: &str = "P2pool.exe";
|
||||||
|
pub const VALID_P2POOL_4: &str = "p2pool.exe";
|
||||||
|
}
|
||||||
|
// --- Valid Unix P2Pool
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
const ACCEPTABLE_P2POOL: [&str; 4] = ["P2POOL", "P2Pool", "P2pool", "p2pool"];
|
pub mod valid_p2pool {
|
||||||
|
pub const VALID_P2POOL_1: &str = "P2POOL";
|
||||||
|
pub const VALID_P2POOL_2: &str = "P2Pool";
|
||||||
|
pub const VALID_P2POOL_3: &str = "P2pool";
|
||||||
|
pub const VALID_P2POOL_4: &str = "p2pool";
|
||||||
|
}
|
||||||
|
use crate::valid_p2pool::*;
|
||||||
|
const VALID_P2POOL: [&str; 4] = [VALID_P2POOL_1, VALID_P2POOL_2, VALID_P2POOL_3, VALID_P2POOL_4];
|
||||||
|
|
||||||
// Some fake Curl/Wget user-agents because GitHub API requires one and a Tor browser
|
// Some fake Curl/Wget user-agents because GitHub API requires one and a Tor browser
|
||||||
// user-agent might be fingerprintable without all the associated headers.
|
// user-agent might be fingerprintable without all the associated headers.
|
||||||
|
@ -178,7 +218,7 @@ pub fn check_p2pool_path(path: &str) -> bool {
|
||||||
Some(p) => p,
|
Some(p) => p,
|
||||||
None => { error!("Couldn't get P2Pool file name"); return false; },
|
None => { error!("Couldn't get P2Pool file name"); return false; },
|
||||||
};
|
};
|
||||||
path == ACCEPTABLE_P2POOL[0] || path == ACCEPTABLE_P2POOL[1] || path == ACCEPTABLE_P2POOL[2] || path == ACCEPTABLE_P2POOL[3]
|
path == VALID_P2POOL[0] || path == VALID_P2POOL[1] || path == VALID_P2POOL[2] || path == VALID_P2POOL[3]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_xmrig_path(path: &str) -> bool {
|
pub fn check_xmrig_path(path: &str) -> bool {
|
||||||
|
@ -190,7 +230,7 @@ pub fn check_xmrig_path(path: &str) -> bool {
|
||||||
Some(p) => p,
|
Some(p) => p,
|
||||||
None => { error!("Couldn't get XMRig file name"); return false; },
|
None => { error!("Couldn't get XMRig file name"); return false; },
|
||||||
};
|
};
|
||||||
path == ACCEPTABLE_XMRIG[0] || path == ACCEPTABLE_XMRIG[1] || path == ACCEPTABLE_XMRIG[2] || path == ACCEPTABLE_XMRIG[3]
|
path == VALID_XMRIG[0] || path == VALID_XMRIG[1] || path == VALID_XMRIG[2] || path == VALID_XMRIG[3]
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Update struct/impl
|
//---------------------------------------------------------------------------------------------------- Update struct/impl
|
||||||
|
@ -323,7 +363,7 @@ impl Update {
|
||||||
info!("Update | Using P2Pool path: [{}]", p2pool_path.display());
|
info!("Update | Using P2Pool path: [{}]", p2pool_path.display());
|
||||||
} else {
|
} else {
|
||||||
warn!("Update | Aborting update, incorrect P2Pool path: [{}]", file);
|
warn!("Update | Aborting update, incorrect P2Pool path: [{}]", file);
|
||||||
let text = format!("Provided P2Pool path seems incorrect. Not starting update for safety.\nTry one of these: {:?}", ACCEPTABLE_P2POOL);
|
let text = format!("Provided P2Pool path seems incorrect. Not starting update for safety.\nTry one of these: {:?}", VALID_P2POOL);
|
||||||
error_state.set(text, ErrorFerris::Error, ErrorButtons::Okay);
|
error_state.set(text, ErrorFerris::Error, ErrorButtons::Okay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +387,7 @@ impl Update {
|
||||||
info!("Update | Using XMRig path: [{}]", xmrig_path.display());
|
info!("Update | Using XMRig path: [{}]", xmrig_path.display());
|
||||||
} else {
|
} else {
|
||||||
warn!("Update | Aborting update, incorrect XMRig path: [{}]", file);
|
warn!("Update | Aborting update, incorrect XMRig path: [{}]", file);
|
||||||
let text = format!("Provided XMRig path seems incorrect. Not starting update for safety.\nTry one of these: {:?}", ACCEPTABLE_XMRIG);
|
let text = format!("Provided XMRig path seems incorrect. Not starting update for safety.\nTry one of these: {:?}", VALID_XMRIG);
|
||||||
error_state.set(text, ErrorFerris::Error, ErrorButtons::Okay);
|
error_state.set(text, ErrorFerris::Error, ErrorButtons::Okay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -665,12 +705,14 @@ impl Update {
|
||||||
if ! entry.file_type().is_file() { continue }
|
if ! entry.file_type().is_file() { continue }
|
||||||
let basename = entry.file_name().to_str().ok_or_else(|| anyhow!("WalkDir basename failed"))?;
|
let basename = entry.file_name().to_str().ok_or_else(|| anyhow!("WalkDir basename failed"))?;
|
||||||
match basename {
|
match basename {
|
||||||
GUPAX_BINARY|P2POOL_BINARY|XMRIG_BINARY => {
|
VALID_GUPAX_1|VALID_GUPAX_2|VALID_GUPAX_3|
|
||||||
|
VALID_P2POOL_1|VALID_P2POOL_2|VALID_P2POOL_3|VALID_P2POOL_4|
|
||||||
|
VALID_XMRIG_1|VALID_XMRIG_2|VALID_XMRIG_3|VALID_XMRIG_4 => {
|
||||||
found = true;
|
found = true;
|
||||||
let name = match basename {
|
let name = match basename {
|
||||||
GUPAX_BINARY => Gupax,
|
VALID_GUPAX_1|VALID_GUPAX_2|VALID_GUPAX_3 => Gupax,
|
||||||
P2POOL_BINARY => P2pool,
|
VALID_P2POOL_1|VALID_P2POOL_2|VALID_P2POOL_3|VALID_P2POOL_4 => P2pool,
|
||||||
_ => Xmrig,
|
_ => Xmrig,
|
||||||
};
|
};
|
||||||
let path = match name {
|
let path = match name {
|
||||||
Gupax => update.lock().unwrap().path_gupax.clone(),
|
Gupax => update.lock().unwrap().path_gupax.clone(),
|
||||||
|
|
Loading…
Reference in a new issue