diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index 4b19832..12103f5 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -82,12 +82,6 @@ jobs: uses: actions/download-artifact@v3 with: path: download-artifact - - name: Cache Qt - id: cache-qt - uses: actions/cache@v3 - with: - path: ${{ runner.workspace }}/Qt - key: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }} - name: Install Qt uses: jurplel/install-qt-action@v3 with: @@ -95,7 +89,8 @@ jobs: py7zrversion: ' ' aqtversion: ' ' setup-python: false - cached: ${{ steps.cache-qt.outputs.cache-hit }} + cache: true + cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }} # ========================================================================================================= Other install - name: Install ninja-build tool uses: seanmiddleditch/gha-setup-ninja@v3 diff --git a/fmt/Bean2CoreObj_ray.cpp b/fmt/Bean2CoreObj_ray.cpp index 47bc2dd..0f6246c 100644 --- a/fmt/Bean2CoreObj_ray.cpp +++ b/fmt/Bean2CoreObj_ray.cpp @@ -10,8 +10,7 @@ outbound["streamSettings"] = streamSettings; namespace NekoRay::fmt { QJsonObject V2rayStreamSettings::BuildStreamSettingsV2Ray() { QJsonObject streamSettings{ - {"network", network}, - {"security", security}, + {"network", network}, }; if (network == "ws") { @@ -54,6 +53,7 @@ namespace NekoRay::fmt { tls["alpn"] = QList2QJsonArray(alpn.split(",")); } streamSettings["tlsSettings"] = tls; + streamSettings["security"] = "tls"; } if (!header_type.isEmpty()) { diff --git a/fmt/InsecureHint.cpp b/fmt/InsecureHint.cpp index 15cfc47..631c6e1 100644 --- a/fmt/InsecureHint.cpp +++ b/fmt/InsecureHint.cpp @@ -35,7 +35,7 @@ namespace NekoRay::fmt { QString VMessBean::InsecureHint() { if (security == "none" || security == "zero") { - if (stream->security.isEmpty() || stream->security == "none") { + if (stream->security.isEmpty()) { return QObject::tr( "This profile is cleartext, don't use it if the server is not in your local network."); } @@ -51,14 +51,14 @@ namespace NekoRay::fmt { } QString TrojanVLESSBean::InsecureHint() { - if (stream->security.isEmpty() || stream->security == "none") { + if (stream->security.isEmpty()) { return QObject::tr("This profile is cleartext, don't use it if the server is not in your local network."); } return {}; } QString SocksHttpBean::InsecureHint() { - if (stream->security.isEmpty() || stream->security == "none") { + if (stream->security.isEmpty()) { return QObject::tr("This profile is cleartext, don't use it if the server is not in your local network."); } return {}; diff --git a/fmt/Link2Bean.cpp b/fmt/Link2Bean.cpp index 9b1fbaf..942ebf7 100644 --- a/fmt/Link2Bean.cpp +++ b/fmt/Link2Bean.cpp @@ -35,7 +35,7 @@ namespace NekoRay::fmt { password = url.password(); if (serverPort == -1) serverPort = socks_http_type == type_HTTP ? 443 : 1080; - stream->security = GetQueryValue(query, "security", "") == "true" ? "tls" : "none"; + stream->security = GetQueryValue(query, "security", ""); stream->sni = GetQueryValue(query, "sni"); } return true; @@ -124,13 +124,7 @@ namespace NekoRay::fmt { auto scy = objN["scy"].toString(); if (!scy.isEmpty()) security = scy; // TLS (XTLS?) - if (!objN["tls"].toString().isEmpty() && objN["tls"].toString().toLower() != "none") - stream->security = "tls"; - if (stream->security == "tls" && IsIpAddress(serverAddress) && - (!stream->host.isEmpty()) && stream->sni.isEmpty()) { - // v2rayN config builder generate sni like this, so set sni here for their format. - stream->sni = stream->host; - } + stream->security = objN["tls"].toString(); // TODO quic & kcp return true; } diff --git a/fmt/Preset.hpp b/fmt/Preset.hpp index 133c2b0..8431e2f 100644 --- a/fmt/Preset.hpp +++ b/fmt/Preset.hpp @@ -5,6 +5,7 @@ namespace Preset { inline const char *command = "--no-check -c %config%"; inline const char *config = "{\n" " \"server\": \"127.0.0.1:%mapping_port%\",\n" + " \"server_name\": \"example.com\",\n" " \"obfs\": \"fuck me till the daylight\",\n" " \"up_mbps\": 10,\n" " \"down_mbps\": 50,\n" diff --git a/sub/GroupUpdater.cpp b/sub/GroupUpdater.cpp index a0f3755..b73540c 100644 --- a/sub/GroupUpdater.cpp +++ b/sub/GroupUpdater.cpp @@ -45,9 +45,11 @@ namespace NekoRay::sub { } QSharedPointer ent; + bool needFix = true; // Nekoray format if (str.startsWith("nekoray://")) { + needFix = false; auto link = QUrl(str); if (!link.isValid()) return; ent = ProfileManager::NewProxyEntity(link.host()); @@ -87,7 +89,7 @@ namespace NekoRay::sub { if (!ok) return; } - // VMess + // VLESS if (str.startsWith("vless://")) { ent = ProfileManager::NewProxyEntity("vless"); auto ok = ent->TrojanVLESSBean()->TryParseLink(str); @@ -103,6 +105,7 @@ namespace NekoRay::sub { // Naive if (str.startsWith("naive+")) { + needFix = false; ent = ProfileManager::NewProxyEntity("naive"); auto ok = ent->NaiveBean()->TryParseLink(str); if (!ok) return; @@ -110,6 +113,7 @@ namespace NekoRay::sub { // Hysteria if (str.startsWith("hysteria://")) { + needFix = false; // https://github.com/HyNetwork/hysteria/wiki/URI-Scheme ent = ProfileManager::NewProxyEntity("custom"); auto bean = ent->CustomBean(); @@ -122,6 +126,7 @@ namespace NekoRay::sub { bean->core = "hysteria"; bean->command = QString(Preset::Hysteria::command).split(" "); auto result = QString2QJsonObject(Preset::Hysteria::config); + result["server_name"] = url.host(); // default sni result["obfs"] = query.queryItemValue("obfsParam"); result["insecure"] = query.queryItemValue("insecure") == "1"; result["up_mbps"] = query.queryItemValue("upmbps").toInt(); @@ -133,6 +138,22 @@ namespace NekoRay::sub { bean->config_simple = QJsonObject2QString(result, false); } + // Fix + auto stream = fmt::GetStreamSettings(ent->bean.get()); + if (needFix && stream != nullptr) { + // 1. "security" + if (stream->security == "none" || stream->security == "0" || stream->security == "false") { + stream->security = ""; + } else if (stream->security == "xtls" || stream->security == "1" || stream->security == "true") { + stream->security = "tls"; + } + // 2. TLS SNI: v2rayN config builder generate sni like this, so set sni here for their format. + if (stream->security == "tls" && IsIpAddress(ent->bean->serverAddress) + && (!stream->host.isEmpty()) && stream->sni.isEmpty()) { + stream->sni = stream->host; + } + } + // End if (ent == nullptr) return; profileManager->AddProfile(ent, gid_add_to); diff --git a/ui/dialog_basic_settings.cpp b/ui/dialog_basic_settings.cpp index 8ae7b49..d5c3817 100644 --- a/ui/dialog_basic_settings.cpp +++ b/ui/dialog_basic_settings.cpp @@ -154,7 +154,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent) // CACHE.extraCore = QString2QJsonObject(NekoRay::dataStore->extraCore->core_map); if (!CACHE.extraCore.contains("naive")) CACHE.extraCore.insert("naive", ""); - if (!CACHE.extraCore.contains("hysteria")) CACHE.extraCore.insert("hysteria", ""); + if (!CACHE.extraCore.contains("hysteria") && !IS_NEKO_BOX) CACHE.extraCore.insert("hysteria", ""); // auto extra_core_layout = ui->extra_core_box->layout(); for (const auto &s: CACHE.extraCore.keys()) { diff --git a/ui/edit/dialog_edit_profile.cpp b/ui/edit/dialog_edit_profile.cpp index 84151df..04a9dae 100644 --- a/ui/edit/dialog_edit_profile.cpp +++ b/ui/edit/dialog_edit_profile.cpp @@ -83,7 +83,6 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId, } ADJUST_SIZE }); - ui->security->removeItem(0); // 确定模式和 ent newEnt = _type != ""; diff --git a/ui/edit/dialog_edit_profile.ui b/ui/edit/dialog_edit_profile.ui index d621d2a..a8d681d 100644 --- a/ui/edit/dialog_edit_profile.ui +++ b/ui/edit/dialog_edit_profile.ui @@ -198,11 +198,6 @@ - - - none - - tls