mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
feat: add warning popup for windows about xmrig outside of Gupaxx
if an xmrig instance run on Windows OS outside of Gupaxx, the later can freeze since xmrig has been started without "below priority". A popup warning the user in the case a xmrig instance is detected whithout the xmrig process started in Gupaxx is added in this commit.
This commit is contained in:
parent
eff8573ed5
commit
e0ece356a0
3 changed files with 40 additions and 2 deletions
|
@ -1,4 +1,8 @@
|
|||
use super::App;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::errors::{process_running, ErrorButtons, ErrorFerris};
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::helper::ProcessName;
|
||||
use crate::helper::ProcessState;
|
||||
use crate::macros::lock;
|
||||
use crate::SECOND;
|
||||
|
@ -63,7 +67,16 @@ impl eframe::App for App {
|
|||
self.size.y = ui.available_height();
|
||||
});
|
||||
self.resize(ctx);
|
||||
|
||||
// check for windows that a local instance of xmrig is not running outside of Gupaxx. Important because it could lead to crashes on this platform.
|
||||
// Warn only once per restart of Gupaxx.
|
||||
#[cfg(target_os = "windows")]
|
||||
if !self.xmrig_outside_warning_acknowledge
|
||||
&& process_running(ProcessName::Xmrig)
|
||||
&& !xmrig_is_alive
|
||||
{
|
||||
self.error_state.set("An instance of xmrig is running outside of Gupaxx.\nThis is not supported and could lead to crashes on this platform.\nPlease stop your local instance and start xmrig from Gupaxx Xmrig tab.", ErrorFerris::Error, ErrorButtons::Okay);
|
||||
self.xmrig_outside_warning_acknowledge = true;
|
||||
}
|
||||
// If there's an error, display [ErrorState] on the whole screen until user responds
|
||||
debug!("App | Checking if there is an error in [ErrorState]");
|
||||
if self.error_state.error {
|
||||
|
|
|
@ -144,6 +144,8 @@ pub struct App {
|
|||
pub pool_path: PathBuf, // Pool file path
|
||||
pub version: &'static str, // Gupax version
|
||||
pub name_version: String, // [Gupax vX.X.X]
|
||||
#[cfg(target_os = "windows")]
|
||||
pub xmrig_outside_warning_acknowledge: bool,
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
@ -306,6 +308,8 @@ impl App {
|
|||
pool_path: PathBuf::new(),
|
||||
version: GUPAX_VERSION,
|
||||
name_version: format!("Gupaxx {}", GUPAX_VERSION),
|
||||
#[cfg(target_os = "windows")]
|
||||
xmrig_outside_warning_acknowledge: false,
|
||||
};
|
||||
//---------------------------------------------------------------------------------------------------- App init data that *could* panic
|
||||
info!("App Init | Getting EXE path...");
|
||||
|
@ -601,7 +605,6 @@ impl App {
|
|||
error!("Unix | Regular user not detected: [{:?}]", id);
|
||||
app.error_state.set(format!("Gupaxx was launched as: [{:?}]\nPlease launch Gupax with regular user permissions.", id), ErrorFerris::Panic, ErrorButtons::Quit);
|
||||
}
|
||||
|
||||
// macOS re-locates "dangerous" applications into some read-only "/private" directory.
|
||||
// It _seems_ to be fixed by moving [Gupax.app] into "/Applications".
|
||||
// So, detect if we are in in "/private" and warn the user.
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use sysinfo::System;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::helper::ProcessName;
|
||||
|
||||
use super::sudo::SudoState;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [ErrorState] struct
|
||||
|
@ -91,3 +97,19 @@ impl ErrorState {
|
|||
SudoState::reset(state)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn process_running(process_name: ProcessName) -> bool {
|
||||
let name = match process_name {
|
||||
ProcessName::P2pool => "p2pool",
|
||||
ProcessName::Xmrig => "xmrig",
|
||||
ProcessName::XmrigProxy => "xmrig-proxy",
|
||||
ProcessName::Node => "monerod",
|
||||
ProcessName::Xvb => panic!("XvB does not exist as a process outside of Gupaxx"),
|
||||
};
|
||||
let s = System::new_all();
|
||||
if s.processes_by_name(name.as_ref()).next().is_some() {
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue