From d6de7e4affd46efec4885d10fbe6a91529631c40 Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Sun, 9 Apr 2023 12:58:23 +0900 Subject: [PATCH] gui: VLESS Flow --- fmt/Bean2CoreObj_box.cpp | 1 + fmt/Bean2Link.cpp | 8 ++++++++ fmt/Link2Bean.cpp | 8 ++++++++ fmt/TrojanVLESSBean.hpp | 2 ++ ui/edit/edit_trojan_vless.cpp | 10 +++++++++- ui/edit/edit_trojan_vless.ui | 25 +++++++++++++++++++++++-- 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/fmt/Bean2CoreObj_box.cpp b/fmt/Bean2CoreObj_box.cpp index 0dfa7bc..2934c05 100644 --- a/fmt/Bean2CoreObj_box.cpp +++ b/fmt/Bean2CoreObj_box.cpp @@ -125,6 +125,7 @@ namespace NekoRay::fmt { QJsonObject settings; if (proxy_type == proxy_VLESS) { outbound["uuid"] = password.trimmed(); + outbound["flow"] = flow; } else { outbound["password"] = password; } diff --git a/fmt/Bean2Link.cpp b/fmt/Bean2Link.cpp index 874fa38..ea12877 100644 --- a/fmt/Bean2Link.cpp +++ b/fmt/Bean2Link.cpp @@ -39,6 +39,7 @@ namespace NekoRay::fmt { if (!stream->sni.isEmpty()) query.addQueryItem("sni", stream->sni); if (stream->allow_insecure) query.addQueryItem("allowInsecure", "1"); + if (IS_NEKO_BOX && !stream->utlsFingerprint.isEmpty()) query.addQueryItem("fp", stream->utlsFingerprint); if (security == "reality") { query.addQueryItem("pbk", stream->reality_pbk); @@ -60,6 +61,13 @@ namespace NekoRay::fmt { } } + // protocol + if (proxy_type == proxy_VLESS) { + if (!flow.isEmpty()) { + query.addQueryItem("flow", flow); + } + } + url.setQuery(query); return url.toString(QUrl::FullyEncoded); } diff --git a/fmt/Link2Bean.cpp b/fmt/Link2Bean.cpp index 93d9b6d..acc17a5 100644 --- a/fmt/Link2Bean.cpp +++ b/fmt/Link2Bean.cpp @@ -55,6 +55,7 @@ namespace NekoRay::fmt { password = url.userName(); if (serverPort == -1) serverPort = 443; + // security stream->network = GetQueryValue(query, "type", "tcp"); stream->security = GetQueryValue(query, "security", "tls").replace("reality", "tls"); auto sni1 = GetQueryValue(query, "sni"); @@ -64,7 +65,9 @@ namespace NekoRay::fmt { if (!query.queryItemValue("allowInsecure").isEmpty()) stream->allow_insecure = true; stream->reality_pbk = GetQueryValue(query, "pbk", ""); stream->reality_sid = GetQueryValue(query, "sid", ""); + if (IS_NEKO_BOX) stream->utlsFingerprint = GetQueryValue(query, "fp", ""); + // type if (stream->network == "ws") { stream->path = GetQueryValue(query, "path", ""); stream->host = GetQueryValue(query, "host", ""); @@ -80,6 +83,11 @@ namespace NekoRay::fmt { } } + // protocol + if (proxy_type == proxy_VLESS) { + flow = GetQueryValue(query, "flow", ""); + } + return !password.isEmpty(); } diff --git a/fmt/TrojanVLESSBean.hpp b/fmt/TrojanVLESSBean.hpp index d044f45..7dc2fc7 100644 --- a/fmt/TrojanVLESSBean.hpp +++ b/fmt/TrojanVLESSBean.hpp @@ -11,6 +11,7 @@ namespace NekoRay::fmt { int proxy_type = proxy_Trojan; QString password = ""; + QString flow = ""; QSharedPointer stream = QSharedPointer(new V2rayStreamSettings()); QString custom = ""; @@ -18,6 +19,7 @@ namespace NekoRay::fmt { explicit TrojanVLESSBean(int _proxy_type) : AbstractBean(0) { proxy_type = _proxy_type; _add(new configItem("pass", &password, itemType::string)); + _add(new configItem("flow", &flow, itemType::string)); _add(new configItem("stream", dynamic_cast(stream.get()), itemType::jsonStore)); _add(new configItem("custom", &custom, itemType::string)); }; diff --git a/ui/edit/edit_trojan_vless.cpp b/ui/edit/edit_trojan_vless.cpp index 5622a30..c72e9a8 100644 --- a/ui/edit/edit_trojan_vless.cpp +++ b/ui/edit/edit_trojan_vless.cpp @@ -14,12 +14,20 @@ EditTrojanVLESS::~EditTrojanVLESS() { void EditTrojanVLESS::onStart(QSharedPointer _ent) { this->ent = _ent; auto bean = this->ent->TrojanVLESSBean(); - if (bean->proxy_type == NekoRay::fmt::TrojanVLESSBean::proxy_VLESS) ui->label->setText("UUID"); + if (bean->proxy_type == NekoRay::fmt::TrojanVLESSBean::proxy_VLESS) { + ui->label->setText("UUID"); + } + if (!IS_NEKO_BOX || bean->proxy_type != NekoRay::fmt::TrojanVLESSBean::proxy_VLESS) { + ui->flow->hide(); + ui->flow_l->hide(); + } ui->password->setText(bean->password); + ui->flow->setCurrentText(bean->flow); } bool EditTrojanVLESS::onEnd() { auto bean = this->ent->TrojanVLESSBean(); bean->password = ui->password->text(); + bean->flow = ui->flow->currentText(); return true; } diff --git a/ui/edit/edit_trojan_vless.ui b/ui/edit/edit_trojan_vless.ui index 5ea3180..01b2657 100644 --- a/ui/edit/edit_trojan_vless.ui +++ b/ui/edit/edit_trojan_vless.ui @@ -14,6 +14,9 @@ + + + @@ -21,8 +24,26 @@ - - + + + + Flow + + + + + + + + + + + + + xtls-rprx-vision + + +