Tun on after request admin

This commit is contained in:
arm64v8a
2023-07-14 14:11:38 +09:00
parent 3c4556e78c
commit decc31bee1
3 changed files with 8 additions and 3 deletions

View File

@@ -87,6 +87,7 @@ namespace NekoGui {
bool flag_tray = false; bool flag_tray = false;
bool flag_debug = false; bool flag_debug = false;
bool flag_linux_run_core_as_admin = false; bool flag_linux_run_core_as_admin = false;
bool flag_restart_tun_on = false;
// Saved // Saved

View File

@@ -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("-tray")) NekoGui::dataStore->flag_tray = true;
if (NekoGui::dataStore->argv.contains("-debug")) NekoGui::dataStore->flag_debug = 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_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 #ifdef NKR_CPP_USE_APPDATA
NekoGui::dataStore->flag_use_appdata = true; // Example: Package & MacOS NekoGui::dataStore->flag_use_appdata = true; // Example: Package & MacOS
#endif #endif

View File

@@ -422,11 +422,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
DS_cores); DS_cores);
// Remember system proxy // 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")) { if (NekoGui::dataStore->remember_spmode.contains("system_proxy")) {
neko_set_spmode_system_proxy(true, false); 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); neko_set_spmode_vpn(true, false);
} }
} }
@@ -688,12 +688,15 @@ void MainWindow::on_menu_exit_triggered() {
if (arguments.length() > 0) { if (arguments.length() > 0) {
arguments.removeFirst(); arguments.removeFirst();
arguments.removeAll("-tray"); arguments.removeAll("-tray");
arguments.removeAll("-flag_restart_tun_on");
} }
auto isLauncher = qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1"; auto isLauncher = qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1";
if (isLauncher) arguments.prepend("--"); if (isLauncher) arguments.prepend("--");
auto program = isLauncher ? "./launcher" : QApplication::applicationFilePath(); 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 #ifdef Q_OS_WIN
WinCommander::runProcessElevated(program, arguments, "", WinCommander::SW_NORMAL, false); WinCommander::runProcessElevated(program, arguments, "", WinCommander::SW_NORMAL, false);
#else #else