Skip to content

Commit

Permalink
feat: utls
Browse files Browse the repository at this point in the history
feat: vpn strict_route
  • Loading branch information
arm64v8a committed Nov 8, 2022
1 parent 99c6a41 commit 9b7f982
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 61 deletions.
1 change: 1 addition & 0 deletions db/ConfigBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ namespace NekoRay {
.replace("%PROCESS_NAME_RULE%", process_name_rule)
.replace("%CIDR_RULE%", cidr_rule)
.replace("%TUN_NAME%", tun_name)
.replace("%STRICT_ROUTE%", dataStore->vpn_strict_route ? "true" : "false")
.replace("%PORT%", Int2String(dataStore->inbound_socks_port));
// write config
QFile file;
Expand Down
1 change: 1 addition & 0 deletions examples/sing-box-vpn.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
%IPV6_ADDRESS%
"mtu": %MTU%,
"auto_route": true,
"strict_route": %STRICT_ROUTE%,
"stack": "%STACK%",
"endpoint_independent_nat": true,
"sniff": false
Expand Down
6 changes: 6 additions & 0 deletions fmt/Bean2CoreObj_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ namespace NekoRay::fmt {
if (!alpn.trimmed().isEmpty()) {
tls["alpn"] = QList2QJsonArray(alpn.split(","));
}
if (!utls.isEmpty()) {
tls["utls"] = QJsonObject{
{"enabled", true},
{"fingerprint", utls},
};
}
outbound->insert("tls", tls);
}

Expand Down
2 changes: 2 additions & 0 deletions fmt/V2RayStreamSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace NekoRay::fmt {
QString sni = "";
QString alpn = "";
QString certificate = "";
QString utls = "";
bool allow_insecure = false;
// ws early data
QString ws_early_data_name = "";
Expand All @@ -35,6 +36,7 @@ namespace NekoRay::fmt {
_add(new configItem("h_type", &header_type, itemType::string));
_add(new configItem("ed_name", &ws_early_data_name, itemType::string));
_add(new configItem("ed_len", &ws_early_data_length, itemType::integer));
_add(new configItem("utls", &utls, itemType::string));
}

QJsonObject BuildStreamSettingsV2Ray();
Expand Down
3 changes: 2 additions & 1 deletion main/NekoRay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ 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("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("check_include_pre", &check_include_pre, itemType::boolean));
Expand Down
3 changes: 2 additions & 1 deletion main/NekoRay_DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ namespace NekoRay {
int vpn_implementation = 0;
int vpn_mtu = 9000;
bool vpn_ipv6 = false;
bool vpn_hide_consloe = false;
bool vpn_hide_console = false;
bool vpn_strict_route = false;
QString vpn_bypass_process = "";
QString vpn_bypass_cidr = "";

Expand Down
8 changes: 0 additions & 8 deletions translations/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,6 @@
<source>Already set</source>
<translation>已设置</translation>
</message>
<message>
<source>Path</source>
<translation>路径(Path)</translation>
</message>
<message>
<source>Host</source>
<translation>主机(Host)</translation>
</message>
<message>
<source>Packet Encoding</source>
<translation>包编码</translation>
Expand Down
27 changes: 0 additions & 27 deletions ui/dialog_basic_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -598,33 +598,6 @@
<header>ui/widget/MyLineEdit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>socks_ip</tabstop>
<tabstop>custom_inbound_edit</tabstop>
<tabstop>inbound_socks_port</tabstop>
<tabstop>inbound_http_port</tabstop>
<tabstop>http_enable</tabstop>
<tabstop>test_url</tabstop>
<tabstop>test_concurrent</tabstop>
<tabstop>log_level</tabstop>
<tabstop>mux_cool_enable</tabstop>
<tabstop>mux_cool</tabstop>
<tabstop>check_include_pre</tabstop>
<tabstop>theme</tabstop>
<tabstop>language</tabstop>
<tabstop>rfsh_r</tabstop>
<tabstop>connection_statistics</tabstop>
<tabstop>start_minimal</tabstop>
<tabstop>user_agent</tabstop>
<tabstop>sub_use_proxy</tabstop>
<tabstop>core_v2ray_asset</tabstop>
<tabstop>core_v2ray_asset_pick</tabstop>
<tabstop>extra_core_add</tabstop>
<tabstop>extra_core_del</tabstop>
<tabstop>insecure_hint</tabstop>
<tabstop>skip_cert</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
Expand Down
6 changes: 4 additions & 2 deletions ui/dialog_vpn_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ DialogVPNSettings::DialogVPNSettings(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);
ui->hide_console->setChecked(NekoRay::dataStore->vpn_hide_console);
#ifndef Q_OS_WIN
ui->hide_console->setVisible(false);
#endif
ui->strict_route->setChecked(NekoRay::dataStore->vpn_strict_route);
//
D_LOAD_STRING(vpn_bypass_cidr)
D_LOAD_STRING(vpn_bypass_process)
Expand All @@ -35,7 +36,8 @@ void DialogVPNSettings::accept() {
NekoRay::dataStore->fake_dns = ui->fake_dns->isChecked();
NekoRay::dataStore->vpn_mtu = mtu;
NekoRay::dataStore->vpn_ipv6 = ui->vpn_ipv6->isChecked();
NekoRay::dataStore->vpn_hide_consloe = ui->hide_console->isChecked();
NekoRay::dataStore->vpn_hide_console = ui->hide_console->isChecked();
NekoRay::dataStore->vpn_strict_route = ui->strict_route->isChecked();
//
D_SAVE_STRING_QTEXTEDIT(vpn_bypass_cidr)
D_SAVE_STRING_QTEXTEDIT(vpn_bypass_process)
Expand Down
16 changes: 7 additions & 9 deletions ui/dialog_vpn_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="strict_route">
<property name="text">
<string notr="true">Strict Route</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -147,15 +154,6 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>vpn_implementation</tabstop>
<tabstop>vpn_mtu</tabstop>
<tabstop>hide_console</tabstop>
<tabstop>vpn_ipv6</tabstop>
<tabstop>fake_dns</tabstop>
<tabstop>vpn_bypass_cidr</tabstop>
<tabstop>vpn_bypass_process</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
Expand Down
2 changes: 2 additions & 0 deletions ui/edit/dialog_edit_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
ui->host->setText(stream->host);
ui->sni->setText(stream->sni);
ui->alpn->setText(stream->alpn);
ui->utls->setCurrentText(stream->utls);
ui->insecure->setChecked(stream->allow_insecure);
ui->header_type->setCurrentText(stream->header_type);
ui->ws_early_data_name->setText(stream->ws_early_data_name);
Expand Down Expand Up @@ -309,6 +310,7 @@ void DialogEditProfile::accept() {
stream->host = ui->host->text();
stream->sni = ui->sni->text();
stream->alpn = ui->alpn->text();
stream->utls = ui->utls->currentText();
stream->allow_insecure = ui->insecure->isChecked();
stream->header_type = ui->header_type->currentText();
stream->ws_early_data_name = ui->ws_early_data_name->text();
Expand Down
115 changes: 103 additions & 12 deletions ui/edit/dialog_edit_profile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ serviceName (gRPC)
key (QUIC)</string>
</property>
<property name="text">
<string>Path</string>
<string notr="true">Path</string>
</property>
</widget>
</item>
Expand All @@ -333,7 +333,7 @@ key (QUIC)</string>
security (QUIC)</string>
</property>
<property name="text">
<string>Host</string>
<string notr="true">Host</string>
</property>
</widget>
</item>
Expand All @@ -346,10 +346,10 @@ security (QUIC)</string>
</sizepolicy>
</property>
<property name="toolTip">
<string notr="true">伪装头部 (tcp/quic)</string>
<string notr="true">伪装头部类型 (tcp/quic)</string>
</property>
<property name="text">
<string notr="true">headerType</string>
<string notr="true">header</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -415,14 +415,104 @@ security (QUIC)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="insecure">
<property name="toolTip">
<string>When enabled, V2Ray will not check the validity of the TLS certificate provided by the remote host (the security is equivalent to plaintext)</string>
</property>
<property name="text">
<string>Allow insecure</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="insecure">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>When enabled, V2Ray will not check the validity of the TLS certificate provided by the remote host (the security is equivalent to plaintext)</string>
</property>
<property name="text">
<string>Allow insecure</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string notr="true">Currently only supported in sing-box core.</string>
</property>
<property name="text">
<string notr="true">uTLS</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="utls">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string notr="true"/>
</property>
</item>
<item>
<property name="text">
<string notr="true">chrome</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">firefox</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">edge</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">safari</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">360</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">qq</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">ios</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">android</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">random</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="_3">
Expand Down Expand Up @@ -501,6 +591,7 @@ security (QUIC)</string>
<tabstop>ws_early_data_length</tabstop>
<tabstop>ws_early_data_name</tabstop>
<tabstop>insecure</tabstop>
<tabstop>utls</tabstop>
<tabstop>sni</tabstop>
<tabstop>alpn</tabstop>
<tabstop>certificate_edit</tabstop>
Expand Down
2 changes: 1 addition & 1 deletion ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ bool MainWindow::StartVPNProcess() {
WinCommander::runProcessElevated(QApplication::applicationDirPath() + "/nekobox_core.exe",
{"--disable-color", "run", "-c", configPath},
"",
NekoRay::dataStore->vpn_hide_consloe
NekoRay::dataStore->vpn_hide_console
); // blocking
vpn_pid = 0;
runOnUiThread([=] {
Expand Down

0 comments on commit 9b7f982

Please sign in to comment.