Skip to content

Commit

Permalink
refactor uot
Browse files Browse the repository at this point in the history
  • Loading branch information
HystericalDragon authored and HystericalDragon committed Jul 17, 2023
1 parent 359c630 commit 8bee6e9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 27 deletions.
11 changes: 10 additions & 1 deletion fmt/Bean2CoreObj_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, ";");
Expand Down
8 changes: 7 additions & 1 deletion fmt/Bean2CoreObj_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fmt/ShadowSocksBean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace NekoGui_fmt {
QString method = "aes-128-gcm";
QString password = "";
QString plugin = "";
bool uot = false;
int uot = 0;

std::shared_ptr<V2rayStreamSettings> stream = std::make_shared<V2rayStreamSettings>();

ShadowSocksBean() : AbstractBean(0) {
_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<JsonStore *>(stream.get()), itemType::jsonStore));
};

Expand Down
4 changes: 2 additions & 2 deletions ui/edit/edit_shadowsocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void EditShadowSocks::onStart(std::shared_ptr<NekoGui::ProxyEntity> _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()) {
Expand All @@ -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();
Expand Down
64 changes: 43 additions & 21 deletions ui/edit/edit_shadowsocks.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Encryption</string>
<item row="0" column="1">
<widget class="QComboBox" name="method">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -31,20 +31,10 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="MyLineEdit" name="plugin_opts"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="method">
<property name="editable">
<bool>true</bool>
<string>Encryption</string>
</property>
</widget>
</item>
Expand All @@ -55,6 +45,16 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="MyLineEdit" name="plugin_opts"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="plugin">
<item>
Expand All @@ -74,16 +74,38 @@
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="uot">
<item row="4" column="0">
<widget class="QLabel" name="uot_l">
<property name="toolTip">
<string>Server support is required</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string notr="true">UDP over TCP</string>
<string>UDP over TCP version</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="uot">
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -101,4 +123,4 @@
</tabstops>
<resources/>
<connections/>
</ui>
</ui>

0 comments on commit 8bee6e9

Please sign in to comment.