mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-16 23:37:47 +00:00
gupax: add [Auto-P2Pool/XMRig] for running at Gupax startup
This commit is contained in:
parent
b65b7a14d8
commit
81ec266e0a
7 changed files with 49 additions and 11 deletions
Binary file not shown.
Before Width: | Height: | Size: 315 KiB After Width: | Height: | Size: 314 KiB |
|
@ -53,7 +53,9 @@ This is how Gupax works internally when starting up:
|
|||
|
||||
2. **AUTO**
|
||||
- If `auto_update` == `true`, spawn auto-updating thread
|
||||
- If `auto_select` == `true`, spawn community node ping thread
|
||||
- If `auto_ping` == `true`, spawn community node ping thread
|
||||
- If `auto_p2pool` == `true`, spawn P2Pool
|
||||
- If `auto_xmrig` == `true`, spawn XMRig
|
||||
|
||||
3. **MAIN**
|
||||
- All data should be initialized at this point, either via `state.toml` or default options
|
||||
|
|
|
@ -121,6 +121,8 @@ pub const GUPAX_UPDATE_VIA_TOR: &str = "Update through the Tor network. Tor is e
|
|||
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: &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!";
|
||||
pub const GUPAX_AUTO_XMRIG: &str = "Automatically start XMRig on Gupax startup. This option will fail if your XMRig settings aren't valid!";
|
||||
pub const GUPAX_WIDTH: &str = "Set the width of the Gupax window";
|
||||
pub const GUPAX_HEIGHT: &str = "Set the height of the Gupax window";
|
||||
pub const GUPAX_LOCK_WIDTH: &str = "Automatically match the HEIGHT against the WIDTH in a 4:3 ratio";
|
||||
|
|
|
@ -142,6 +142,8 @@ impl State {
|
|||
simple: true,
|
||||
auto_update: true,
|
||||
auto_node: true,
|
||||
auto_p2pool: true,
|
||||
auto_xmrig: true,
|
||||
ask_before_quit: true,
|
||||
save_before_quit: true,
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
|
@ -579,6 +581,8 @@ pub struct Gupax {
|
|||
pub simple: bool,
|
||||
pub auto_update: bool,
|
||||
pub auto_node: bool,
|
||||
pub auto_p2pool: bool,
|
||||
pub auto_xmrig: bool,
|
||||
pub ask_before_quit: bool,
|
||||
pub save_before_quit: bool,
|
||||
pub update_via_tor: bool,
|
||||
|
|
11
src/gupax.rs
11
src/gupax.rs
|
@ -114,12 +114,17 @@ impl Gupax {
|
|||
|
||||
ui.horizontal(|ui| {
|
||||
ui.group(|ui| {
|
||||
let width = (width - SPACE*7.5)/4.0;
|
||||
let width = (width - SPACE*12.0)/6.0;
|
||||
let height = height/10.0;
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.auto_update, "Auto-update")).on_hover_text(GUPAX_AUTO_UPDATE);
|
||||
ui.separator();
|
||||
ui.style_mut().override_text_style = Some(egui::TextStyle::Small);
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.update_via_tor, "Update via Tor")).on_hover_text(GUPAX_UPDATE_VIA_TOR);
|
||||
ui.separator();
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.auto_update, "Auto-Update")).on_hover_text(GUPAX_AUTO_UPDATE);
|
||||
ui.separator();
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.auto_p2pool, "Auto-P2Pool")).on_hover_text(GUPAX_AUTO_P2POOL);
|
||||
ui.separator();
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.auto_xmrig, "Auto-XMRig")).on_hover_text(GUPAX_AUTO_XMRIG);
|
||||
ui.separator();
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.ask_before_quit, "Ask before quit")).on_hover_text(GUPAX_ASK_BEFORE_QUIT);
|
||||
ui.separator();
|
||||
ui.add_sized([width, height], Checkbox::new(&mut self.save_before_quit, "Save before quit")).on_hover_text(GUPAX_SAVE_BEFORE_QUIT);
|
||||
|
|
|
@ -405,8 +405,7 @@ impl Helper {
|
|||
}
|
||||
|
||||
// The P2Pool watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
||||
#[tokio::main]
|
||||
async fn spawn_p2pool_watchdog(process: Arc<Mutex<Process>>, gui_api: Arc<Mutex<PubP2poolApi>>, pub_api: Arc<Mutex<PubP2poolApi>>, priv_api: Arc<Mutex<PrivP2poolApi>>, args: Vec<String>, mut path: std::path::PathBuf) {
|
||||
fn spawn_p2pool_watchdog(process: Arc<Mutex<Process>>, gui_api: Arc<Mutex<PubP2poolApi>>, pub_api: Arc<Mutex<PubP2poolApi>>, priv_api: Arc<Mutex<PrivP2poolApi>>, args: Vec<String>, mut path: std::path::PathBuf) {
|
||||
// 1a. Create PTY
|
||||
let pty = portable_pty::native_pty_system();
|
||||
let pair = pty.openpty(portable_pty::PtySize {
|
||||
|
@ -714,8 +713,7 @@ impl Helper {
|
|||
}
|
||||
|
||||
// The P2Pool watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
||||
#[tokio::main]
|
||||
async fn spawn_xmrig_watchdog(process: Arc<Mutex<Process>>, gui_api: Arc<Mutex<PubXmrigApi>>, pub_api: Arc<Mutex<PubXmrigApi>>, priv_api: Arc<Mutex<PrivXmrigApi>>, args: Vec<String>, mut path: std::path::PathBuf, sudo: Arc<Mutex<SudoState>>) {
|
||||
fn spawn_xmrig_watchdog(process: Arc<Mutex<Process>>, gui_api: Arc<Mutex<PubXmrigApi>>, pub_api: Arc<Mutex<PubXmrigApi>>, priv_api: Arc<Mutex<PrivXmrigApi>>, args: Vec<String>, mut path: std::path::PathBuf, sudo: Arc<Mutex<SudoState>>) {
|
||||
// 1a. Create PTY
|
||||
let pty = portable_pty::native_pty_system();
|
||||
let mut pair = pty.openpty(portable_pty::PtySize {
|
||||
|
|
33
src/main.rs
33
src/main.rs
|
@ -601,13 +601,40 @@ fn init_auto(app: &mut App) {
|
|||
}
|
||||
|
||||
// [Auto-Ping]
|
||||
let auto_node = app.og.lock().unwrap().p2pool.auto_node;
|
||||
let simple = app.og.lock().unwrap().p2pool.simple;
|
||||
if auto_node && simple {
|
||||
if app.state.p2pool.auto_node && app.state.p2pool.simple {
|
||||
Ping::spawn_thread(&app.ping)
|
||||
} else {
|
||||
info!("Skipping auto-ping...");
|
||||
}
|
||||
|
||||
// [Auto-P2Pool]
|
||||
if app.state.gupax.auto_p2pool {
|
||||
if !Regexes::addr_ok(&app.regex, &app.state.p2pool.address) {
|
||||
warn!("Gupax | P2Pool address is not valid! Skipping auto-p2pool...");
|
||||
} else if !Gupax::path_is_exe(&app.state.gupax.p2pool_path) {
|
||||
warn!("Gupax | P2Pool path is not an executable! Skipping auto-p2pool...");
|
||||
} else {
|
||||
Helper::start_p2pool(&app.helper, &app.state.p2pool, &app.state.gupax.absolute_p2pool_path);
|
||||
}
|
||||
} else {
|
||||
info!("Skipping auto-xmrig...");
|
||||
}
|
||||
|
||||
// [Auto-XMRig]
|
||||
if app.state.gupax.auto_xmrig {
|
||||
if !Gupax::path_is_exe(&app.state.gupax.xmrig_path) {
|
||||
warn!("Gupax | XMRig path is not an executable! Skipping auto-xmrig...");
|
||||
} else {
|
||||
if cfg!(windows) {
|
||||
Helper::start_xmrig(&app.helper, &app.state.xmrig, &app.state.gupax.absolute_xmrig_path, Arc::clone(&app.sudo));
|
||||
} else {
|
||||
app.sudo.lock().unwrap().signal = ProcessSignal::Start;
|
||||
app.error_state.ask_sudo(&app.sudo);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info!("Skipping auto-xmrig...");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Reset functions
|
||||
|
|
Loading…
Reference in a new issue