diff --git a/include/ui/profile/dialog_edit_profile.ui b/include/ui/profile/dialog_edit_profile.ui index d5ea60a..aa7da63 100644 --- a/include/ui/profile/dialog_edit_profile.ui +++ b/include/ui/profile/dialog_edit_profile.ui @@ -103,101 +103,6 @@ - - - - - 0 - 0 - - - - TLS Security Settings - - - - - - - - - 0 - 0 - - - - When enabled, V2Ray will not check the validity of the TLS certificate provided by the remote host (the security is equivalent to plaintext) - - - Allow insecure - - - - - - - Qt::Orientation::Vertical - - - - - - - - 0 - 0 - - - - - - - Certificate - - - - - - - Edit - - - - - - - - - - - - - - Server name indication, clear text. - - - SNI - - - - - - - Application layer protocol negotiation, clear text. Please separate them with commas. - - - ALPN - - - - - - - - - - - @@ -435,11 +340,6 @@ tls - - - reality - - @@ -636,6 +536,101 @@ + + + + + 0 + 0 + + + + TLS Security Settings + + + + + + + + + 0 + 0 + + + + When enabled, V2Ray will not check the validity of the TLS certificate provided by the remote host (the security is equivalent to plaintext) + + + Allow insecure + + + + + + + Qt::Orientation::Vertical + + + + + + + + 0 + 0 + + + + + + + Certificate + + + + + + + Edit + + + + + + + + + + + + + + Server name indication, clear text. + + + SNI + + + + + + + Application layer protocol negotiation, clear text. Please separate them with commas. + + + ALPN + + + + + + + + + + + @@ -776,6 +771,9 @@ + + Reality short id. Accept only one value. + Reality SID @@ -822,6 +820,9 @@ certificate_edit sni alpn + utlsFingerprint + reality_pbk + reality_sid diff --git a/src/configs/proxy/Bean2CoreObj_box.cpp b/src/configs/proxy/Bean2CoreObj_box.cpp index de3a33f..e81e421 100644 --- a/src/configs/proxy/Bean2CoreObj_box.cpp +++ b/src/configs/proxy/Bean2CoreObj_box.cpp @@ -73,36 +73,15 @@ namespace Configs { if (!alpn.trimmed().isEmpty()) { tls["alpn"] = QListStr2QJsonArray(alpn.split(",")); } - if (QString fp = utlsFingerprint; !fp.isEmpty()) { - tls["utls"] = QJsonObject{ - {"enabled", true}, - {"fingerprint", fp}, - }; - } - if (enable_tls_fragment) - { - tls["fragment"] = enable_tls_fragment; - if (!tls_fragment_fallback_delay.isEmpty()) tls["fragment_fallback_delay"] = tls_fragment_fallback_delay; - } - if (enable_tls_record_fragment) tls["record_fragment"] = enable_tls_record_fragment; - outbound->insert("tls", tls); - } else if (security == "reality") { - QJsonObject tls{{"enabled", true}}; - if (allow_insecure || Configs::dataStore->skip_cert) tls["insecure"] = true; - if (!sni.trimmed().isEmpty()) tls["server_name"] = sni; - if (!certificate.trimmed().isEmpty()) { - tls["certificate"] = certificate.trimmed(); - } - if (!alpn.trimmed().isEmpty()) { - tls["alpn"] = QListStr2QJsonArray(alpn.split(",")); - } - tls["reality"] = QJsonObject{ - {"enabled", true}, - {"public_key", reality_pbk}, - {"short_id", reality_sid.split(",")[0]}, - }; QString fp = utlsFingerprint; - if (fp.isEmpty()) fp = "random"; + if (!reality_pbk.trimmed().isEmpty()) { + tls["reality"] = QJsonObject{ + {"enabled", true}, + {"public_key", reality_pbk}, + {"short_id", reality_sid.split(",")[0]}, + }; + if (fp.isEmpty()) fp = "random"; + } if (!fp.isEmpty()) { tls["utls"] = QJsonObject{ {"enabled", true}, diff --git a/src/configs/proxy/Bean2Link.cpp b/src/configs/proxy/Bean2Link.cpp index 1afa4f2..734ac1c 100644 --- a/src/configs/proxy/Bean2Link.cpp +++ b/src/configs/proxy/Bean2Link.cpp @@ -33,7 +33,9 @@ namespace Configs { if (!name.isEmpty()) url.setFragment(name); // security - query.addQueryItem("security", stream->security == "" ? "none" : stream->security); + auto security = stream->security; + if (security == "tls" && !stream->reality_pbk.trimmed().isEmpty()) security = "reality"; + query.addQueryItem("security", security == "" ? "none" : security); if (!stream->sni.isEmpty()) query.addQueryItem("sni", stream->sni); if (!stream->alpn.isEmpty()) query.addQueryItem("alpn", stream->alpn); @@ -43,7 +45,7 @@ namespace Configs { if (!stream->tls_fragment_fallback_delay.isEmpty()) query.addQueryItem("fragment_fallback_delay", stream->tls_fragment_fallback_delay); if (stream->enable_tls_record_fragment) query.addQueryItem("record_fragment", "1"); - if (stream->security == "reality") { + if (security == "reality") { query.addQueryItem("pbk", stream->reality_pbk); if (!stream->reality_sid.isEmpty()) query.addQueryItem("sid", stream->reality_sid); } @@ -62,7 +64,9 @@ namespace Configs { if (!name.isEmpty()) url.setFragment(name); // security - query.addQueryItem("security", stream->security == "" ? "none" : stream->security); + auto security = stream->security; + if (security == "tls" && !stream->reality_pbk.trimmed().isEmpty()) security = "reality"; + query.addQueryItem("security", security == "" ? "none" : security); if (!stream->sni.isEmpty()) query.addQueryItem("sni", stream->sni); if (!stream->alpn.isEmpty()) query.addQueryItem("alpn", stream->alpn); @@ -72,7 +76,7 @@ namespace Configs { if (!stream->tls_fragment_fallback_delay.isEmpty()) query.addQueryItem("fragment_fallback_delay", stream->tls_fragment_fallback_delay); if (stream->enable_tls_record_fragment) query.addQueryItem("record_fragment", "1"); - if (stream->security == "reality") { + if (security == "reality") { query.addQueryItem("pbk", stream->reality_pbk); if (!stream->reality_sid.isEmpty()) query.addQueryItem("sid", stream->reality_sid); } @@ -168,7 +172,9 @@ namespace Configs { query.addQueryItem("encryption", security); // security - query.addQueryItem("security", stream->security == "" ? "none" : stream->security); + auto security = stream->security; + if (security == "tls" && !stream->reality_pbk.trimmed().isEmpty()) security = "reality"; + query.addQueryItem("security", security == "" ? "none" : security); if (!stream->sni.isEmpty()) query.addQueryItem("sni", stream->sni); if (stream->allow_insecure) query.addQueryItem("allowInsecure", "1"); @@ -181,7 +187,7 @@ namespace Configs { if (!stream->tls_fragment_fallback_delay.isEmpty()) query.addQueryItem("fragment_fallback_delay", stream->tls_fragment_fallback_delay); if (stream->enable_tls_record_fragment) query.addQueryItem("record_fragment", "1"); - if (stream->security == "reality") { + if (security == "reality") { query.addQueryItem("pbk", stream->reality_pbk); if (!stream->reality_sid.isEmpty()) query.addQueryItem("sid", stream->reality_sid); } diff --git a/src/configs/proxy/Json2Bean.cpp b/src/configs/proxy/Json2Bean.cpp index 8e57656..ff2bf14 100644 --- a/src/configs/proxy/Json2Bean.cpp +++ b/src/configs/proxy/Json2Bean.cpp @@ -135,10 +135,6 @@ namespace Configs stream->packet_encoding = obj["packet_encoding"].toString(); mux_state = obj["multiplex"].isObject() ? (obj["multiplex"].toObject()["enabled"].toBool() ? 1 : 2) : 0; stream->security = obj["tls"].isObject() ? "tls" : ""; - if (obj["tls"].toObject()["reality"].toObject()["enabled"].toBool()) - { - stream->security = "reality"; - } stream->reality_pbk = obj["tls"].toObject()["reality"].toObject()["public_key"].toString(); stream->reality_sid = obj["tls"].toObject()["reality"].toObject()["short_id"].toString(); stream->utlsFingerprint = obj["tls"].toObject()["utls"].toObject()["fingerprint"].toString(); @@ -180,10 +176,6 @@ namespace Configs stream->packet_encoding = obj["packet_encoding"].toString(); mux_state = obj["multiplex"].isObject() ? (obj["multiplex"].toObject()["enabled"].toBool() ? 1 : 2) : 0; stream->security = obj["tls"].isObject() ? "tls" : ""; - if (obj["tls"].toObject()["reality"].toObject()["enabled"].toBool()) - { - stream->security = "reality"; - } stream->reality_pbk = obj["tls"].toObject()["reality"].toObject()["public_key"].toString(); stream->reality_sid = obj["tls"].toObject()["reality"].toObject()["short_id"].toString(); stream->utlsFingerprint = obj["tls"].toObject()["utls"].toObject()["fingerprint"].toString(); @@ -224,10 +216,6 @@ namespace Configs idle_session_timeout = obj["idle_session_timeout"].toInt(); min_idle_session = obj["min_idle_session"].toInt(); stream->security = obj["tls"].isObject() ? "tls" : ""; - if (obj["tls"].toObject()["reality"].toObject()["enabled"].toBool()) - { - stream->security = "reality"; - } stream->reality_pbk = obj["tls"].toObject()["reality"].toObject()["public_key"].toString(); stream->reality_sid = obj["tls"].toObject()["reality"].toObject()["short_id"].toString(); stream->utlsFingerprint = obj["tls"].toObject()["utls"].toObject()["fingerprint"].toString(); diff --git a/src/configs/proxy/Link2Bean.cpp b/src/configs/proxy/Link2Bean.cpp index 4017ab3..24c40b0 100644 --- a/src/configs/proxy/Link2Bean.cpp +++ b/src/configs/proxy/Link2Bean.cpp @@ -55,7 +55,7 @@ namespace Configs { // security - stream->security = GetQueryValue(query, "security", "").replace("none", ""); + stream->security = "tls"; auto sni1 = GetQueryValue(query, "sni"); auto sni2 = GetQueryValue(query, "peer"); if (!sni1.isEmpty()) stream->sni = sni1; @@ -71,10 +71,6 @@ namespace Configs { if (stream->utlsFingerprint.isEmpty()) { stream->utlsFingerprint = dataStore->utlsFingerprint; } - if (stream->security.isEmpty()) { - if (!sni1.isEmpty() || !sni2.isEmpty()) stream->security = "tls"; - if (!stream->reality_pbk.isEmpty()) stream->security = "reality"; - } return !(password.isEmpty() || serverAddress.isEmpty()); } @@ -98,7 +94,11 @@ namespace Configs { } stream->network = type; - stream->security = GetQueryValue(query, "security", "").replace("none", ""); + if (proxy_type == proxy_Trojan) { + stream->security = GetQueryValue(query, "security", "tls").replace("reality", "tls").replace("none", ""); + } else { + stream->security = GetQueryValue(query, "security", "").replace("reality", "tls").replace("none", ""); + } auto sni1 = GetQueryValue(query, "sni"); auto sni2 = GetQueryValue(query, "peer"); if (!sni1.isEmpty()) stream->sni = sni1; @@ -116,7 +116,6 @@ namespace Configs { } if (stream->security.isEmpty()) { if (!sni1.isEmpty() || !sni2.isEmpty()) stream->security = "tls"; - if (!stream->reality_pbk.isEmpty()) stream->security = "reality"; } // type diff --git a/src/ui/profile/dialog_edit_profile.cpp b/src/ui/profile/dialog_edit_profile.cpp index 5566d19..1b426b2 100644 --- a/src/ui/profile/dialog_edit_profile.cpp +++ b/src/ui/profile/dialog_edit_profile.cpp @@ -116,17 +116,6 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId, if (txt == "tls") { ui->security_box->setVisible(true); ui->tls_camouflage_box->setVisible(true); - ui->reality_pbk->setVisible(false); - ui->reality_pbk_l->setVisible(false); - ui->reality_sid->setVisible(false); - ui->reality_sid_l->setVisible(false); - } else if (txt == "reality") { - ui->security_box->setVisible(true); - ui->tls_camouflage_box->setVisible(true); - ui->reality_pbk->setVisible(true); - ui->reality_pbk_l->setVisible(true); - ui->reality_sid->setVisible(true); - ui->reality_sid_l->setVisible(true); } else { ui->security_box->setVisible(false); ui->tls_camouflage_box->setVisible(false);