From 8bee6e9ea275f447192cbc64c62e6bffd43294f0 Mon Sep 17 00:00:00 2001 From: HystericalDragon <138737572+HystericalDragon@users.noreply.github.com> Date: Mon, 17 Jul 2023 16:46:50 +0800 Subject: [PATCH] refactor uot --- fmt/Bean2CoreObj_box.cpp | 11 +++++- fmt/Bean2CoreObj_ray.cpp | 8 ++++- fmt/ShadowSocksBean.hpp | 4 +-- ui/edit/edit_shadowsocks.cpp | 4 +-- ui/edit/edit_shadowsocks.ui | 66 ++++++++++++++++++++++++------------ 5 files changed, 65 insertions(+), 28 deletions(-) diff --git a/fmt/Bean2CoreObj_box.cpp b/fmt/Bean2CoreObj_box.cpp index 6c2480c..0f22a22 100644 --- a/fmt/Bean2CoreObj_box.cpp +++ b/fmt/Bean2CoreObj_box.cpp @@ -106,7 +106,16 @@ namespace NekoGui_fmt { outbound["server_port"] = serverPort; outbound["method"] = method; outbound["password"] = password; - outbound["udp_over_tcp"] = uot; + + if (uot != 0) { + QJsonObject udp_over_tcp{ + {"enabled", true}, + {"version", uot}, + }; + outbound["udp_over_tcp"] = udp_over_tcp; + } else { + outbound["udp_over_tcp"] = false; + } if (!plugin.trimmed().isEmpty()) { outbound["plugin"] = SubStrBefore(plugin, ";"); diff --git a/fmt/Bean2CoreObj_ray.cpp b/fmt/Bean2CoreObj_ray.cpp index ac8d4ba..477631b 100644 --- a/fmt/Bean2CoreObj_ray.cpp +++ b/fmt/Bean2CoreObj_ray.cpp @@ -116,7 +116,13 @@ namespace NekoGui_fmt { server["port"] = serverPort; server["method"] = method; server["password"] = password; - server["uot"] = uot; + + if (uot != 0) { + server["uot"] = true; + server["UoTVersion"] = uot; + } else { + server["uot"] = false; + } servers.push_back(server); settings["servers"] = servers; diff --git a/fmt/ShadowSocksBean.hpp b/fmt/ShadowSocksBean.hpp index 2db40d3..3bf58d9 100644 --- a/fmt/ShadowSocksBean.hpp +++ b/fmt/ShadowSocksBean.hpp @@ -9,7 +9,7 @@ namespace NekoGui_fmt { QString method = "aes-128-gcm"; QString password = ""; QString plugin = ""; - bool uot = false; + int uot = 0; std::shared_ptr stream = std::make_shared(); @@ -17,7 +17,7 @@ namespace NekoGui_fmt { _add(new configItem("method", &method, itemType::string)); _add(new configItem("pass", &password, itemType::string)); _add(new configItem("plugin", &plugin, itemType::string)); - _add(new configItem("uot", &uot, itemType::boolean)); + _add(new configItem("uot", &uot, itemType::integer)); _add(new configItem("stream", dynamic_cast(stream.get()), itemType::jsonStore)); }; diff --git a/ui/edit/edit_shadowsocks.cpp b/ui/edit/edit_shadowsocks.cpp index adee498..eb8c34f 100644 --- a/ui/edit/edit_shadowsocks.cpp +++ b/ui/edit/edit_shadowsocks.cpp @@ -19,7 +19,7 @@ void EditShadowSocks::onStart(std::shared_ptr _ent) { auto bean = this->ent->ShadowSocksBean(); ui->method->setCurrentText(bean->method); - ui->uot->setChecked(bean->uot); + ui->uot->setCurrentText(Int2String(bean->uot)); ui->password->setText(bean->password); auto ssPlugin = bean->plugin.split(";"); if (!ssPlugin.empty()) { @@ -33,7 +33,7 @@ bool EditShadowSocks::onEnd() { bean->method = ui->method->currentText(); bean->password = ui->password->text(); - bean->uot = ui->uot->isChecked(); + bean->uot = ui->uot->currentText().toInt();; bean->plugin = ui->plugin->currentText(); if (!bean->plugin.isEmpty()) { bean->plugin += ";" + ui->plugin_opts->text(); diff --git a/ui/edit/edit_shadowsocks.ui b/ui/edit/edit_shadowsocks.ui index 00d85ad..bd1fbb7 100644 --- a/ui/edit/edit_shadowsocks.ui +++ b/ui/edit/edit_shadowsocks.ui @@ -14,10 +14,10 @@ Form - - - - Encryption + + + + true @@ -31,20 +31,10 @@ - - - - - + + - Password - - - - - - - true + Encryption @@ -55,6 +45,16 @@ + + + + + + + Password + + + @@ -74,14 +74,36 @@ - - + + Server support is required - - UDP over TCP + + + + UDP over TCP version + + + + + + + + 0 + + + + + 1 + + + + + 2 + + @@ -101,4 +123,4 @@ - + \ No newline at end of file