mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
feat: vpn hide console
This commit is contained in:
9
3rdparty/WinCommander.cpp
vendored
9
3rdparty/WinCommander.cpp
vendored
@@ -44,7 +44,8 @@ Returns the return value of the executed command
|
||||
*/
|
||||
uint WinCommander::runProcessElevated(const QString &path,
|
||||
const QStringList ¶meters,
|
||||
const QString &workingDir, bool aWait) {
|
||||
const QString &workingDir,
|
||||
bool hide, bool aWait) {
|
||||
uint result = 0;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -75,7 +76,7 @@ uint WinCommander::runProcessElevated(const QString &path,
|
||||
shex.lpParameters = pszParameters;
|
||||
shex.lpDirectory = pszDirectory;
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
|
||||
shex.nShow = SW_SHOWMINIMIZED;
|
||||
shex.nShow = hide ? SW_HIDE : SW_SHOWMINIMIZED;
|
||||
|
||||
ShellExecuteEx(&shex);
|
||||
if (shex.hProcess)
|
||||
@@ -109,6 +110,6 @@ execution or wait for the exit of the launched process
|
||||
Returns the return value of the executed command
|
||||
*/
|
||||
uint WinCommander::runProcessElevated(const QString &path, const QString ¶meters, const QString &workingDir,
|
||||
bool aWait) {
|
||||
return runProcessElevated(path, QStringList() << parameters, workingDir, aWait);
|
||||
bool hide, bool aWait) {
|
||||
return runProcessElevated(path, QStringList() << parameters, workingDir, hide, aWait);
|
||||
}
|
||||
|
||||
4
3rdparty/WinCommander.hpp
vendored
4
3rdparty/WinCommander.hpp
vendored
@@ -31,12 +31,12 @@ public:
|
||||
static uint runProcessElevated(const QString &path,
|
||||
const QStringList ¶meters = QStringList(),
|
||||
const QString &workingDir = QString(),
|
||||
bool aWait = true);
|
||||
bool hide = false, bool aWait = true);
|
||||
|
||||
static uint runProcessElevated(const QString &path,
|
||||
const QString ¶meters = QString(),
|
||||
const QString &workingDir = QString(),
|
||||
bool aWait = true);
|
||||
bool hide = false, bool aWait = true);
|
||||
};
|
||||
|
||||
#endif // WINCOMMANDER_H
|
||||
@@ -53,6 +53,7 @@ namespace NekoRay {
|
||||
_add(new configItem("vpn_impl", &vpn_implementation, itemType::integer));
|
||||
_add(new configItem("vpn_mtu", &vpn_mtu, itemType::integer));
|
||||
_add(new configItem("vpn_ipv6", &vpn_ipv6, itemType::boolean));
|
||||
_add(new configItem("vpn_hide_console", &vpn_hide_consloe, itemType::boolean));
|
||||
_add(new configItem("check_include_pre", &check_include_pre, itemType::boolean));
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace NekoRay {
|
||||
int vpn_implementation = 0;
|
||||
int vpn_mtu = 9000;
|
||||
bool vpn_ipv6 = false;
|
||||
bool vpn_hide_consloe = false;
|
||||
|
||||
// Hotkey
|
||||
QString hotkey_mainwindow = "";
|
||||
|
||||
@@ -482,6 +482,10 @@
|
||||
<source>VPN Enable IPv6</source>
|
||||
<translation>启用 VPN IPv6</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Hide Console</source>
|
||||
<translation>隐藏控制台</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditChain</name>
|
||||
|
||||
@@ -44,6 +44,10 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) :
|
||||
ui->vpn_implementation->setCurrentIndex(NekoRay::dataStore->vpn_implementation);
|
||||
ui->vpn_mtu->setCurrentText(Int2String(NekoRay::dataStore->vpn_mtu));
|
||||
ui->vpn_ipv6->setChecked(NekoRay::dataStore->vpn_ipv6);
|
||||
ui->hide_console->setChecked(NekoRay::dataStore->vpn_hide_consloe);
|
||||
#ifndef Q_OS_WIN
|
||||
ui->hide_console->setVisible(false);
|
||||
#endif
|
||||
//
|
||||
#ifdef Q_OS_WIN
|
||||
ui->vpn_implementation->setItemText(0, Preset::SingBox::VpnImplementation[0]);
|
||||
@@ -122,6 +126,7 @@ void DialogManageRoutes::accept() {
|
||||
NekoRay::dataStore->fake_dns = fakedns;
|
||||
NekoRay::dataStore->vpn_mtu = mtu;
|
||||
NekoRay::dataStore->vpn_ipv6 = ipv6;
|
||||
NekoRay::dataStore->vpn_hide_consloe = ui->hide_console->isChecked();
|
||||
//
|
||||
bool routeChanged = false;
|
||||
if (NekoRay::dataStore->active_routing != active_routing) routeChanged = true;
|
||||
|
||||
@@ -175,6 +175,19 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hide_console">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide Console</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="vpn_ipv6">
|
||||
<property name="sizePolicy">
|
||||
|
||||
@@ -1405,7 +1405,10 @@ bool MainWindow::StartVPNProcess() {
|
||||
runOnNewThread([=] {
|
||||
vpn_pid = 1; //TODO get pid?
|
||||
WinCommander::runProcessElevated(QApplication::applicationDirPath() + "/sing-box.exe",
|
||||
{"--disable-color", "run", "-c", configPath}); // blocking
|
||||
{"--disable-color", "run", "-c", configPath},
|
||||
"",
|
||||
NekoRay::dataStore->vpn_hide_consloe
|
||||
); // blocking
|
||||
vpn_pid = 0;
|
||||
runOnUiThread([=] {
|
||||
neko_set_spmode(NekoRay::SystemProxyMode::DISABLE);
|
||||
|
||||
Reference in New Issue
Block a user