mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
Tun on after request admin
This commit is contained in:
@@ -87,6 +87,7 @@ namespace NekoGui {
|
||||
bool flag_tray = false;
|
||||
bool flag_debug = false;
|
||||
bool flag_linux_run_core_as_admin = false;
|
||||
bool flag_restart_tun_on = false;
|
||||
|
||||
// Saved
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ int main(int argc, char* argv[]) {
|
||||
if (NekoGui::dataStore->argv.contains("-tray")) NekoGui::dataStore->flag_tray = true;
|
||||
if (NekoGui::dataStore->argv.contains("-debug")) NekoGui::dataStore->flag_debug = true;
|
||||
if (NekoGui::dataStore->argv.contains("-flag_linux_run_core_as_admin")) NekoGui::dataStore->flag_linux_run_core_as_admin = true;
|
||||
if (NekoGui::dataStore->argv.contains("-flag_restart_tun_on")) NekoGui::dataStore->flag_restart_tun_on = true;
|
||||
#ifdef NKR_CPP_USE_APPDATA
|
||||
NekoGui::dataStore->flag_use_appdata = true; // Example: Package & MacOS
|
||||
#endif
|
||||
|
||||
@@ -422,11 +422,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
DS_cores);
|
||||
|
||||
// Remember system proxy
|
||||
if (NekoGui::dataStore->remember_enable) {
|
||||
if (NekoGui::dataStore->remember_enable || NekoGui::dataStore->flag_restart_tun_on) {
|
||||
if (NekoGui::dataStore->remember_spmode.contains("system_proxy")) {
|
||||
neko_set_spmode_system_proxy(true, false);
|
||||
}
|
||||
if (NekoGui::dataStore->remember_spmode.contains("vpn")) {
|
||||
if (NekoGui::dataStore->remember_spmode.contains("vpn") || NekoGui::dataStore->flag_restart_tun_on) {
|
||||
neko_set_spmode_vpn(true, false);
|
||||
}
|
||||
}
|
||||
@@ -688,12 +688,15 @@ void MainWindow::on_menu_exit_triggered() {
|
||||
if (arguments.length() > 0) {
|
||||
arguments.removeFirst();
|
||||
arguments.removeAll("-tray");
|
||||
arguments.removeAll("-flag_restart_tun_on");
|
||||
}
|
||||
auto isLauncher = qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1";
|
||||
if (isLauncher) arguments.prepend("--");
|
||||
auto program = isLauncher ? "./launcher" : QApplication::applicationFilePath();
|
||||
|
||||
if (exit_reason == 3) { // restart as admin
|
||||
if (exit_reason == 3) {
|
||||
// Tun restart as admin
|
||||
arguments << "-flag_restart_tun_on";
|
||||
#ifdef Q_OS_WIN
|
||||
WinCommander::runProcessElevated(program, arguments, "", WinCommander::SW_NORMAL, false);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user