mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-31 06:39:00 +08:00
optimize vpn
This commit is contained in:
parent
1f4263acd1
commit
bbde5bc0e9
@ -611,6 +611,25 @@
|
||||
<source>Proxy Process Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Troubleshooting</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>If you have trouble starting VPN, you can force reset nekobox_core process here.
|
||||
|
||||
If still not working, see documentation for more information.
|
||||
https://matsuridayo.github.io/n-configuration/#vpn-tun</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset</source>
|
||||
<translation type="unfinished">بازنشانی</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished">لغو کردن</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditChain</name>
|
||||
|
||||
@ -617,6 +617,28 @@
|
||||
<source>Whether blacklisted or whitelisted, your traffic will be handled by nekobox_core (sing-tun). This is NOT equal to "process mode" of some software.</source>
|
||||
<translation>无论是黑名单还是白名单,您的流量都将由 nekobox_core (sing-tun) 处理。这不等于某些软件的「进程模式」。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Troubleshooting</source>
|
||||
<translation>故障排除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>If you have trouble starting VPN, you can force reset nekobox_core process here.
|
||||
|
||||
If still not working, see documentation for more information.
|
||||
https://matsuridayo.github.io/n-configuration/#vpn-tun</source>
|
||||
<translation>如果您在启动 VPN 时遇到问题,您可以在此处强制重置 nekobox_core 进程。
|
||||
|
||||
如果仍然无法正常工作,请参阅文档以获取更多信息。
|
||||
https://matsuridayo.github.io/n-configuration/#vpn-tun</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset</source>
|
||||
<translation>重置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditChain</name>
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
|
||||
#include "main/GuiUtils.hpp"
|
||||
#include "main/NekoRay.hpp"
|
||||
#include "ui/mainwindow_interface.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
|
||||
ui->setupUi(this);
|
||||
@ -57,3 +60,15 @@ void DialogVPNSettings::accept() {
|
||||
MW_dialog_message("", "UpdateDataStore,VPNChanged");
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void DialogVPNSettings::on_troubleshooting_clicked() {
|
||||
auto r = QMessageBox::information(this, tr("Troubleshooting"),
|
||||
tr("If you have trouble starting VPN, you can force reset nekobox_core process here.\n\n"
|
||||
"If still not working, see documentation for more information.\n"
|
||||
"https://matsuridayo.github.io/n-configuration/#vpn-tun"),
|
||||
tr("Reset"), tr("Cancel"), "",
|
||||
1, 1);
|
||||
if (r == 0) {
|
||||
GetMainWindow()->StopVPNProcess(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,9 @@ private:
|
||||
public slots:
|
||||
|
||||
void accept() override;
|
||||
|
||||
void on_troubleshooting_clicked();
|
||||
|
||||
};
|
||||
|
||||
#endif // NEKORAY_DIALOG_VPN_SETTINGS_H
|
||||
|
||||
@ -157,6 +157,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="troubleshooting">
|
||||
<property name="text">
|
||||
<string>Troubleshooting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
|
||||
@ -1684,8 +1684,8 @@ bool MainWindow::StartVPNProcess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::StopVPNProcess() {
|
||||
if (vpn_pid != 0) {
|
||||
bool MainWindow::StopVPNProcess(bool unconditional) {
|
||||
if (unconditional || vpn_pid != 0) {
|
||||
bool ok;
|
||||
core_process->processId();
|
||||
#ifdef Q_OS_WIN
|
||||
@ -1699,15 +1699,17 @@ bool MainWindow::StopVPNProcess() {
|
||||
p.start("osascript", {"-e", QString("do shell script \"%1\" with administrator privileges")
|
||||
.arg("pkill -2 -U 0 nekobox_core")});
|
||||
#else
|
||||
p.start("pkexec", {"pkill", "-2", "-P", Int2String(vpn_pid)});
|
||||
if (unconditional) {
|
||||
p.start("pkexec", {"killall", "nekobox_core"});
|
||||
} else {
|
||||
p.start("pkexec", {"pkill", "-2", "-P", Int2String(vpn_pid)});
|
||||
}
|
||||
#endif
|
||||
p.waitForFinished();
|
||||
ok = p.exitCode() == 0;
|
||||
#endif
|
||||
if (ok) {
|
||||
vpn_pid = 0;
|
||||
} else {
|
||||
MessageBoxWarning(tr("Error"), tr("Failed to stop VPN process"));
|
||||
if (!unconditional) {
|
||||
ok ? vpn_pid = 0 : MessageBoxWarning(tr("Error"), tr("Failed to stop VPN process"));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -61,6 +61,8 @@ public:
|
||||
|
||||
void RegisterHotkey(bool unregister);
|
||||
|
||||
bool StopVPNProcess(bool unconditional = false);
|
||||
|
||||
signals:
|
||||
|
||||
void profile_selected(int id);
|
||||
@ -173,8 +175,6 @@ private:
|
||||
|
||||
bool StartVPNProcess();
|
||||
|
||||
bool StopVPNProcess();
|
||||
|
||||
// grpc and ...
|
||||
|
||||
void setup_grpc();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user