mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 13:04:37 +03:00
vpn final outbound rule GUI
This commit is contained in:
@@ -865,21 +865,28 @@ namespace NekoRay {
|
||||
}
|
||||
|
||||
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
|
||||
QString process_name_rule = dataStore->vpn_bypass_process.trimmed();
|
||||
QString process_name_rule = dataStore->vpn_rule_process.trimmed();
|
||||
if (!process_name_rule.isEmpty()) {
|
||||
auto arr = SplitLinesSkipSharp(process_name_rule);
|
||||
QJsonObject rule{{"outbound", "direct"},
|
||||
QJsonObject rule{{"outbound", match_out},
|
||||
{"process_name", QList2QJsonArray(arr)}};
|
||||
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()) {
|
||||
auto arr = SplitLinesSkipSharp(cidr_rule);
|
||||
QJsonObject rule{{"outbound", "direct"},
|
||||
QJsonObject rule{{"outbound", match_out},
|
||||
{"ip_cidr", QList2QJsonArray(arr)}};
|
||||
cidr_rule = "," + QJsonObject2QString(rule, false);
|
||||
}
|
||||
// no_match_rule
|
||||
auto no_match_rule = QJsonObject{
|
||||
{"port_range", ":"},
|
||||
{"outbound", no_match_out},
|
||||
};
|
||||
// tun name
|
||||
auto tun_name = "nekoray-tun";
|
||||
#ifdef Q_OS_MACOS
|
||||
@@ -903,6 +910,7 @@ namespace NekoRay {
|
||||
.replace("%TUN_NAME%", tun_name)
|
||||
.replace("%STRICT_ROUTE%", dataStore->vpn_strict_route ? "true" : "false")
|
||||
.replace("%SOCKS_USER_PASS%", socks_user_pass)
|
||||
.replace("%NO_MATCH_RULE%", "," + QJsonObject2QString(no_match_rule, false))
|
||||
.replace("%PORT%", Int2String(dataStore->inbound_socks_port));
|
||||
// hook.js
|
||||
auto source = qjs::ReadHookJS();
|
||||
|
||||
@@ -80,3 +80,17 @@
|
||||
#else
|
||||
#define ACTIVE_THIS_WINDOW _ACTIVE_THIS_WINDOW_COMMON
|
||||
#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_hide_console", &vpn_hide_console, 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_cidr", &vpn_bypass_cidr, itemType::string));
|
||||
_add(new configItem("vpn_bypass_process", &vpn_rule_process, 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("sp_format", &system_proxy_format, itemType::string));
|
||||
_add(new configItem("sub_clear", &sub_clear, itemType::boolean));
|
||||
|
||||
@@ -133,8 +133,9 @@ namespace NekoRay {
|
||||
bool vpn_ipv6 = false;
|
||||
bool vpn_hide_console = false;
|
||||
bool vpn_strict_route = false;
|
||||
QString vpn_bypass_process = "";
|
||||
QString vpn_bypass_cidr = "";
|
||||
bool vpn_rule_white = false;
|
||||
QString vpn_rule_process = "";
|
||||
QString vpn_rule_cidr = "";
|
||||
|
||||
// Hotkey
|
||||
QString hotkey_mainwindow = "";
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
}
|
||||
%PROCESS_NAME_RULE%
|
||||
%CIDR_RULE%
|
||||
%NO_MATCH_RULE%
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -583,6 +583,22 @@
|
||||
<source>Bypass Process Name</source>
|
||||
<translation type="unfinished"></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 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>
|
||||
<name>EditChain</name>
|
||||
|
||||
@@ -589,6 +589,22 @@
|
||||
<source>Bypass Process Name</source>
|
||||
<translation>绕过进程名</translation>
|
||||
</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>
|
||||
<name>EditChain</name>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
|
||||
ui->setupUi(this);
|
||||
ADD_ASTERISK(this);
|
||||
|
||||
ui->fake_dns->setVisible(!IS_NEKO_BOX);
|
||||
ui->fake_dns->setChecked(NekoRay::dataStore->fake_dns);
|
||||
@@ -19,8 +20,19 @@ DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new
|
||||
#endif
|
||||
ui->strict_route->setChecked(NekoRay::dataStore->vpn_strict_route);
|
||||
//
|
||||
D_LOAD_STRING(vpn_bypass_cidr)
|
||||
D_LOAD_STRING(vpn_bypass_process)
|
||||
D_LOAD_STRING(vpn_rule_cidr)
|
||||
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() {
|
||||
@@ -37,9 +49,10 @@ void DialogVPNSettings::accept() {
|
||||
NekoRay::dataStore->vpn_ipv6 = ui->vpn_ipv6->isChecked();
|
||||
NekoRay::dataStore->vpn_hide_console = ui->hide_console->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_bypass_process)
|
||||
D_SAVE_STRING_QTEXTEDIT(vpn_rule_cidr)
|
||||
D_SAVE_STRING_QTEXTEDIT(vpn_rule_process)
|
||||
//
|
||||
MW_dialog_message("", "UpdateDataStore,VPNChanged");
|
||||
QDialog::accept();
|
||||
|
||||
@@ -120,25 +120,25 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="verticalGroupBox">
|
||||
<widget class="QGroupBox" name="gb_cidr">
|
||||
<property name="title">
|
||||
<string>Bypass CIDR</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="vpn_bypass_cidr"/>
|
||||
<widget class="QTextEdit" name="vpn_rule_cidr"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="verticalGroupBox_2">
|
||||
<widget class="QGroupBox" name="gb_process_name">
|
||||
<property name="title">
|
||||
<string>Bypass Process Name</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="vpn_bypass_process"/>
|
||||
<widget class="QTextEdit" name="vpn_rule_process"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -146,11 +146,25 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="whitelist_mode">
|
||||
<property name="toolTip">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -248,12 +248,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
||||
ui->port->setValidator(QRegExpValidator_Number);
|
||||
|
||||
// 星号
|
||||
for (auto label: findChildren<QLabel *>()) {
|
||||
auto text = label->text();
|
||||
if (!label->toolTip().isEmpty() && !text.endsWith("*")) {
|
||||
label->setText(text + "*");
|
||||
}
|
||||
}
|
||||
ADD_ASTERISK(this);
|
||||
|
||||
// 设置 for NekoBox
|
||||
if (IS_NEKO_BOX) {
|
||||
|
||||
Reference in New Issue
Block a user