refactor uot

This commit is contained in:
HystericalDragon
2023-07-17 16:46:50 +08:00
parent 359c630c20
commit 8bee6e9ea2
5 changed files with 65 additions and 28 deletions

View File

@@ -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, ";");

View File

@@ -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;

View File

@@ -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<V2rayStreamSettings> stream = std::make_shared<V2rayStreamSettings>();
@@ -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<JsonStore *>(stream.get()), itemType::jsonStore));
};

View File

@@ -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()) {
@@ -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();

View File

@@ -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>
@@ -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>
@@ -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>
@@ -74,14 +74,36 @@
</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="text">
<string notr="true">UDP over TCP</string>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<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>
@@ -101,4 +123,4 @@
</tabstops>
<resources/>
<connections/>
</ui>
</ui>