gui: reality settings

This commit is contained in:
arm64v8a
2023-04-07 17:07:32 +09:00
parent 089acaebb5
commit 1d8fdc7a7d
9 changed files with 144 additions and 43 deletions

View File

@@ -41,6 +41,13 @@ namespace NekoRay::fmt {
{"fingerprint", fp},
};
}
if (!reality_pbk.trimmed().isEmpty()) {
tls["reality"] = QJsonObject{
{"enabled", true},
{"public_key", reality_pbk},
{"short_id", reality_sid},
};
}
outbound->insert("tls", tls);
}

View File

@@ -31,9 +31,21 @@ namespace NekoRay::fmt {
url.setHost(serverAddress);
url.setPort(serverPort);
if (!name.isEmpty()) url.setFragment(name);
// security
auto security = stream->security;
if (security == "tls" && !stream->reality_pbk.trimmed().isEmpty()) security = "reality";
query.addQueryItem("security", security);
if (!stream->sni.isEmpty()) query.addQueryItem("sni", stream->sni);
if (stream->allow_insecure) query.addQueryItem("allowInsecure", "1");
query.addQueryItem("security", stream->security);
if (security == "reality") {
query.addQueryItem("pbk", stream->reality_pbk);
query.addQueryItem("sid", stream->reality_sid);
}
// type
query.addQueryItem("type", stream->network);
if (stream->network == "ws" || stream->network == "http") {

View File

@@ -38,6 +38,8 @@ namespace NekoRay::fmt {
stream->security = GetQueryValue(query, "security", "");
stream->sni = GetQueryValue(query, "sni");
if (link.startsWith("https")) stream->security = "tls";
}
return true;
}
@@ -54,14 +56,15 @@ namespace NekoRay::fmt {
if (serverPort == -1) serverPort = 443;
stream->network = GetQueryValue(query, "type", "tcp");
stream->security = GetQueryValue(query, "security", "tls");
stream->security = GetQueryValue(query, "security", "tls").replace("reality", "tls");
auto sni1 = GetQueryValue(query, "sni");
auto sni2 = GetQueryValue(query, "peer");
if (!sni1.isEmpty()) stream->sni = sni1;
if (!sni2.isEmpty()) stream->sni = sni2;
if (!query.queryItemValue("allowInsecure").isEmpty()) stream->allow_insecure = true;
stream->reality_pbk = GetQueryValue(query, "pbk", "");
stream->reality_sid = GetQueryValue(query, "sid", "");
// TODO header kcp quic
if (stream->network == "ws") {
stream->path = GetQueryValue(query, "path", "");
stream->host = GetQueryValue(query, "host", "");

View File

@@ -22,6 +22,9 @@ namespace NekoRay::fmt {
// ws early data
QString ws_early_data_name = "";
int ws_early_data_length = 0;
// reality
QString reality_pbk = "";
QString reality_sid = "";
V2rayStreamSettings() : JsonStore() {
_add(new configItem("net", &network, itemType::string));
@@ -37,6 +40,8 @@ namespace NekoRay::fmt {
_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", &utlsFingerprint, itemType::string));
_add(new configItem("pbk", &reality_pbk, itemType::string));
_add(new configItem("sid", &reality_sid, itemType::string));
}
QJsonObject BuildStreamSettingsV2Ray();

View File

@@ -353,7 +353,7 @@
</message>
<message>
<source>Security Settings</source>
<translation>تنظیمات امنیت</translation>
<translation type="vanished">تنظیمات امنیت</translation>
</message>
<message>
<source>When enabled, V2Ray will not check the validity of the TLS certificate provided by the remote host (the security is equivalent to plaintext)</source>
@@ -391,6 +391,18 @@
<source>Already set</source>
<translation>تنظیم شده</translation>
</message>
<message>
<source>TLS Security Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TLS Camouflage Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reality public key. If not empty, turn TLS into REALITY.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DialogHotkey</name>

View File

@@ -345,13 +345,9 @@
<source>Application layer protocol negotiation, clear text. Please separate them with commas.</source>
<translation></translation>
</message>
<message>
<source>Security Settings</source>
<translation></translation>
</message>
<message>
<source>Allow insecure</source>
<translation></translation>
<translation></translation>
</message>
<message>
<source>Certificate</source>
@@ -385,6 +381,18 @@
<source>Custom (%1)</source>
<translation> (%1)</translation>
</message>
<message>
<source>TLS Security Settings</source>
<translation>TLS </translation>
</message>
<message>
<source>TLS Camouflage Settings</source>
<translation>TLS </translation>
</message>
<message>
<source>Reality public key. If not empty, turn TLS into REALITY.</source>
<translation>Reality public key. TLS REALITY</translation>
</message>
</context>
<context>
<name>DialogHotkey</name>

View File

@@ -664,7 +664,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="horizontalGroupBox">
<widget class="QGroupBox" name="horizontalGroupBox3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>

View File

@@ -94,8 +94,16 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
connect(ui->security, &QComboBox::currentTextChanged, this, [=](const QString &txt) {
if (txt == "tls") {
ui->security_box->setVisible(true);
ui->reality_box->setVisible(true);
if (!IS_NEKO_BOX) {
ui->reality_pbk->hide();
ui->reality_sid->hide();
ui->reality_pbk_l->hide();
ui->reality_sid_l->hide();
}
} else {
ui->security_box->setVisible(false);
ui->reality_box->setVisible(false);
}
ADJUST_SIZE
});
@@ -196,7 +204,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
ui->port->setVisible(showAddressPort);
ui->port_l->setVisible(showAddressPort);
// 右边 Outbound: settings
// 右边 stream
auto stream = GetStreamSettings(ent->bean.data());
if (stream != nullptr) {
ui->right_all_w->setVisible(true);
@@ -212,6 +220,8 @@ void DialogEditProfile::typeSelected(const QString &newType) {
ui->header_type->setCurrentText(stream->header_type);
ui->ws_early_data_name->setText(stream->ws_early_data_name);
ui->ws_early_data_length->setText(Int2String(stream->ws_early_data_length));
ui->reality_pbk->setText(stream->reality_pbk);
ui->reality_sid->setText(stream->reality_sid);
CACHE.certificate = stream->certificate;
} else {
ui->right_all_w->setVisible(false);
@@ -310,7 +320,7 @@ void DialogEditProfile::accept() {
return;
}
// 右边
// 右边 stream
auto stream = GetStreamSettings(ent->bean.data());
if (stream != nullptr) {
stream->network = ui->network->currentText();
@@ -326,7 +336,11 @@ void DialogEditProfile::accept() {
stream->ws_early_data_name = ui->ws_early_data_name->text();
stream->ws_early_data_length = ui->ws_early_data_length->text().toInt();
stream->certificate = CACHE.certificate;
stream->reality_pbk = ui->reality_pbk->text();
stream->reality_sid = ui->reality_sid->text();
}
// cached custom
auto custom_item = ent->bean->_get("custom");
if (custom_item != nullptr) {
*((QString *) custom_item->ptr) = CACHE.custom;

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>678</height>
<height>800</height>
</rect>
</property>
<property name="sizePolicy">
@@ -130,7 +130,7 @@
<item>
<widget class="QPushButton" name="custom_edit">
<property name="text">
<string>Edit</string>
<string notr="true">Edit</string>
</property>
</widget>
</item>
@@ -411,7 +411,7 @@ security (QUIC)</string>
</sizepolicy>
</property>
<property name="title">
<string>Security Settings</string>
<string>TLS Security Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@@ -440,38 +440,13 @@ security (QUIC)</string>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">uTLS</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="utlsFingerprint">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="_3">
<item row="2" column="1">
<widget class="QPushButton" name="certificate_edit">
<property name="text">
<string notr="true">PushButton</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="toolTip">
<string notr="true"/>
</property>
@@ -480,6 +455,17 @@ security (QUIC)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="certificate_edit">
<property name="text">
<string notr="true">Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="_3">
<item row="0" column="1">
<widget class="MyLineEdit" name="sni"/>
</item>
@@ -511,6 +497,58 @@ security (QUIC)</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="reality_box">
<property name="title">
<string>TLS Camouflage Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="reality_pbk_l">
<property name="toolTip">
<string>Reality public key. If not empty, turn TLS into REALITY.</string>
</property>
<property name="text">
<string notr="true">Realty Pbk</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="reality_sid_l">
<property name="text">
<string notr="true">Reality Sid</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="MyLineEdit" name="reality_sid"/>
</item>
<item row="1" column="1">
<widget class="MyLineEdit" name="reality_pbk"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">uTLS</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="utlsFingerprint">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@@ -538,10 +576,12 @@ security (QUIC)</string>
<tabstop>ws_early_data_length</tabstop>
<tabstop>ws_early_data_name</tabstop>
<tabstop>insecure</tabstop>
<tabstop>utlsFingerprint</tabstop>
<tabstop>certificate_edit</tabstop>
<tabstop>sni</tabstop>
<tabstop>alpn</tabstop>
<tabstop>certificate_edit</tabstop>
<tabstop>utlsFingerprint</tabstop>
<tabstop>reality_pbk</tabstop>
<tabstop>reality_sid</tabstop>
</tabstops>
<resources/>
<connections>