mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
vpn final outbound rule GUI
This commit is contained in:
parent
c58f231b2c
commit
2482a5b48f
@ -865,21 +865,28 @@ namespace NekoRay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString WriteVPNSingBoxConfig() {
|
QString WriteVPNSingBoxConfig() {
|
||||||
|
auto match_out = NekoRay::dataStore->vpn_rule_white ? "proxy" : "direct";
|
||||||
|
auto no_match_out = NekoRay::dataStore->vpn_rule_white ? "direct" : "proxy";
|
||||||
// user rule
|
// user rule
|
||||||
QString process_name_rule = dataStore->vpn_bypass_process.trimmed();
|
QString process_name_rule = dataStore->vpn_rule_process.trimmed();
|
||||||
if (!process_name_rule.isEmpty()) {
|
if (!process_name_rule.isEmpty()) {
|
||||||
auto arr = SplitLinesSkipSharp(process_name_rule);
|
auto arr = SplitLinesSkipSharp(process_name_rule);
|
||||||
QJsonObject rule{{"outbound", "direct"},
|
QJsonObject rule{{"outbound", match_out},
|
||||||
{"process_name", QList2QJsonArray(arr)}};
|
{"process_name", QList2QJsonArray(arr)}};
|
||||||
process_name_rule = "," + QJsonObject2QString(rule, false);
|
process_name_rule = "," + QJsonObject2QString(rule, false);
|
||||||
}
|
}
|
||||||
QString cidr_rule = dataStore->vpn_bypass_cidr.trimmed();
|
QString cidr_rule = dataStore->vpn_rule_cidr.trimmed();
|
||||||
if (!cidr_rule.isEmpty()) {
|
if (!cidr_rule.isEmpty()) {
|
||||||
auto arr = SplitLinesSkipSharp(cidr_rule);
|
auto arr = SplitLinesSkipSharp(cidr_rule);
|
||||||
QJsonObject rule{{"outbound", "direct"},
|
QJsonObject rule{{"outbound", match_out},
|
||||||
{"ip_cidr", QList2QJsonArray(arr)}};
|
{"ip_cidr", QList2QJsonArray(arr)}};
|
||||||
cidr_rule = "," + QJsonObject2QString(rule, false);
|
cidr_rule = "," + QJsonObject2QString(rule, false);
|
||||||
}
|
}
|
||||||
|
// no_match_rule
|
||||||
|
auto no_match_rule = QJsonObject{
|
||||||
|
{"port_range", ":"},
|
||||||
|
{"outbound", no_match_out},
|
||||||
|
};
|
||||||
// tun name
|
// tun name
|
||||||
auto tun_name = "nekoray-tun";
|
auto tun_name = "nekoray-tun";
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
@ -903,6 +910,7 @@ namespace NekoRay {
|
|||||||
.replace("%TUN_NAME%", tun_name)
|
.replace("%TUN_NAME%", tun_name)
|
||||||
.replace("%STRICT_ROUTE%", dataStore->vpn_strict_route ? "true" : "false")
|
.replace("%STRICT_ROUTE%", dataStore->vpn_strict_route ? "true" : "false")
|
||||||
.replace("%SOCKS_USER_PASS%", socks_user_pass)
|
.replace("%SOCKS_USER_PASS%", socks_user_pass)
|
||||||
|
.replace("%NO_MATCH_RULE%", "," + QJsonObject2QString(no_match_rule, false))
|
||||||
.replace("%PORT%", Int2String(dataStore->inbound_socks_port));
|
.replace("%PORT%", Int2String(dataStore->inbound_socks_port));
|
||||||
// hook.js
|
// hook.js
|
||||||
auto source = qjs::ReadHookJS();
|
auto source = qjs::ReadHookJS();
|
||||||
|
|||||||
@ -80,3 +80,17 @@
|
|||||||
#else
|
#else
|
||||||
#define ACTIVE_THIS_WINDOW _ACTIVE_THIS_WINDOW_COMMON
|
#define ACTIVE_THIS_WINDOW _ACTIVE_THIS_WINDOW_COMMON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ADD_ASTERISK(parent) \
|
||||||
|
for (auto label: parent->findChildren<QLabel *>()) { \
|
||||||
|
auto text = label->text(); \
|
||||||
|
if (!label->toolTip().isEmpty() && !text.endsWith("*")) { \
|
||||||
|
label->setText(text + "*"); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
for (auto checkBox: parent->findChildren<QCheckBox *>()) { \
|
||||||
|
auto text = checkBox->text(); \
|
||||||
|
if (!checkBox->toolTip().isEmpty() && !text.endsWith("*")) { \
|
||||||
|
checkBox->setText(text + "*"); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|||||||
@ -60,8 +60,9 @@ namespace NekoRay {
|
|||||||
_add(new configItem("vpn_ipv6", &vpn_ipv6, itemType::boolean));
|
_add(new configItem("vpn_ipv6", &vpn_ipv6, itemType::boolean));
|
||||||
_add(new configItem("vpn_hide_console", &vpn_hide_console, itemType::boolean));
|
_add(new configItem("vpn_hide_console", &vpn_hide_console, itemType::boolean));
|
||||||
_add(new configItem("vpn_strict_route", &vpn_strict_route, itemType::boolean));
|
_add(new configItem("vpn_strict_route", &vpn_strict_route, itemType::boolean));
|
||||||
_add(new configItem("vpn_bypass_process", &vpn_bypass_process, itemType::string));
|
_add(new configItem("vpn_bypass_process", &vpn_rule_process, itemType::string));
|
||||||
_add(new configItem("vpn_bypass_cidr", &vpn_bypass_cidr, itemType::string));
|
_add(new configItem("vpn_bypass_cidr", &vpn_rule_cidr, itemType::string));
|
||||||
|
_add(new configItem("vpn_rule_white", &vpn_rule_white, itemType::boolean));
|
||||||
_add(new configItem("check_include_pre", &check_include_pre, itemType::boolean));
|
_add(new configItem("check_include_pre", &check_include_pre, itemType::boolean));
|
||||||
_add(new configItem("sp_format", &system_proxy_format, itemType::string));
|
_add(new configItem("sp_format", &system_proxy_format, itemType::string));
|
||||||
_add(new configItem("sub_clear", &sub_clear, itemType::boolean));
|
_add(new configItem("sub_clear", &sub_clear, itemType::boolean));
|
||||||
|
|||||||
@ -133,8 +133,9 @@ namespace NekoRay {
|
|||||||
bool vpn_ipv6 = false;
|
bool vpn_ipv6 = false;
|
||||||
bool vpn_hide_console = false;
|
bool vpn_hide_console = false;
|
||||||
bool vpn_strict_route = false;
|
bool vpn_strict_route = false;
|
||||||
QString vpn_bypass_process = "";
|
bool vpn_rule_white = false;
|
||||||
QString vpn_bypass_cidr = "";
|
QString vpn_rule_process = "";
|
||||||
|
QString vpn_rule_cidr = "";
|
||||||
|
|
||||||
// Hotkey
|
// Hotkey
|
||||||
QString hotkey_mainwindow = "";
|
QString hotkey_mainwindow = "";
|
||||||
|
|||||||
@ -95,6 +95,7 @@
|
|||||||
}
|
}
|
||||||
%PROCESS_NAME_RULE%
|
%PROCESS_NAME_RULE%
|
||||||
%CIDR_RULE%
|
%CIDR_RULE%
|
||||||
|
%NO_MATCH_RULE%
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -583,6 +583,22 @@
|
|||||||
<source>Bypass Process Name</source>
|
<source>Bypass Process Name</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<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 type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Whitelist mode</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Proxy CIDR</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Proxy Process Name</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>EditChain</name>
|
<name>EditChain</name>
|
||||||
|
|||||||
@ -589,6 +589,22 @@
|
|||||||
<source>Bypass Process Name</source>
|
<source>Bypass Process Name</source>
|
||||||
<translation>绕过进程名</translation>
|
<translation>绕过进程名</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Whitelist mode</source>
|
||||||
|
<translation>白名单模式</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Proxy CIDR</source>
|
||||||
|
<translation>代理 CIDR</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Proxy Process Name</source>
|
||||||
|
<translation>代理进程名</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<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>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>EditChain</name>
|
<name>EditChain</name>
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
|
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ADD_ASTERISK(this);
|
||||||
|
|
||||||
ui->fake_dns->setVisible(!IS_NEKO_BOX);
|
ui->fake_dns->setVisible(!IS_NEKO_BOX);
|
||||||
ui->fake_dns->setChecked(NekoRay::dataStore->fake_dns);
|
ui->fake_dns->setChecked(NekoRay::dataStore->fake_dns);
|
||||||
@ -19,8 +20,19 @@ DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new
|
|||||||
#endif
|
#endif
|
||||||
ui->strict_route->setChecked(NekoRay::dataStore->vpn_strict_route);
|
ui->strict_route->setChecked(NekoRay::dataStore->vpn_strict_route);
|
||||||
//
|
//
|
||||||
D_LOAD_STRING(vpn_bypass_cidr)
|
D_LOAD_STRING(vpn_rule_cidr)
|
||||||
D_LOAD_STRING(vpn_bypass_process)
|
D_LOAD_STRING(vpn_rule_process)
|
||||||
|
//
|
||||||
|
connect(ui->whitelist_mode, &QCheckBox::stateChanged, this, [=](int state) {
|
||||||
|
if (state == Qt::Checked) {
|
||||||
|
ui->gb_cidr->setTitle(tr("Proxy CIDR"));
|
||||||
|
ui->gb_process_name->setTitle(tr("Proxy Process Name"));
|
||||||
|
} else {
|
||||||
|
ui->gb_cidr->setTitle(tr("Bypass CIDR"));
|
||||||
|
ui->gb_process_name->setTitle(tr("Bypass Process Name"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui->whitelist_mode->setChecked(NekoRay::dataStore->vpn_rule_white);
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogVPNSettings::~DialogVPNSettings() {
|
DialogVPNSettings::~DialogVPNSettings() {
|
||||||
@ -37,9 +49,10 @@ void DialogVPNSettings::accept() {
|
|||||||
NekoRay::dataStore->vpn_ipv6 = ui->vpn_ipv6->isChecked();
|
NekoRay::dataStore->vpn_ipv6 = ui->vpn_ipv6->isChecked();
|
||||||
NekoRay::dataStore->vpn_hide_console = ui->hide_console->isChecked();
|
NekoRay::dataStore->vpn_hide_console = ui->hide_console->isChecked();
|
||||||
NekoRay::dataStore->vpn_strict_route = ui->strict_route->isChecked();
|
NekoRay::dataStore->vpn_strict_route = ui->strict_route->isChecked();
|
||||||
|
NekoRay::dataStore->vpn_rule_white = ui->whitelist_mode->isChecked();
|
||||||
//
|
//
|
||||||
D_SAVE_STRING_QTEXTEDIT(vpn_bypass_cidr)
|
D_SAVE_STRING_QTEXTEDIT(vpn_rule_cidr)
|
||||||
D_SAVE_STRING_QTEXTEDIT(vpn_bypass_process)
|
D_SAVE_STRING_QTEXTEDIT(vpn_rule_process)
|
||||||
//
|
//
|
||||||
MW_dialog_message("", "UpdateDataStore,VPNChanged");
|
MW_dialog_message("", "UpdateDataStore,VPNChanged");
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
|||||||
@ -120,25 +120,25 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="verticalGroupBox">
|
<widget class="QGroupBox" name="gb_cidr">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Bypass CIDR</string>
|
<string>Bypass CIDR</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="vpn_bypass_cidr"/>
|
<widget class="QTextEdit" name="vpn_rule_cidr"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="verticalGroupBox_2">
|
<widget class="QGroupBox" name="gb_process_name">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Bypass Process Name</string>
|
<string>Bypass Process Name</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="vpn_bypass_process"/>
|
<widget class="QTextEdit" name="vpn_rule_process"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -146,11 +146,25 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="standardButtons">
|
<item>
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<widget class="QCheckBox" name="whitelist_mode">
|
||||||
</property>
|
<property name="toolTip">
|
||||||
</widget>
|
<string>Whether blacklisted or whitelisted, your traffic will be handled by nekobox_core (sing-tun). This is NOT equal to "process mode" of some software.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Whitelist mode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@ -248,12 +248,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
|||||||
ui->port->setValidator(QRegExpValidator_Number);
|
ui->port->setValidator(QRegExpValidator_Number);
|
||||||
|
|
||||||
// 星号
|
// 星号
|
||||||
for (auto label: findChildren<QLabel *>()) {
|
ADD_ASTERISK(this);
|
||||||
auto text = label->text();
|
|
||||||
if (!label->toolTip().isEmpty() && !text.endsWith("*")) {
|
|
||||||
label->setText(text + "*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置 for NekoBox
|
// 设置 for NekoBox
|
||||||
if (IS_NEKO_BOX) {
|
if (IS_NEKO_BOX) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user