fix packet encoding (#774)

* feat(sub): get packet encoding from Clash.Meta's sub

* fix: use "packetaddr" instead of "packet"

* fix

* fix

---------

Co-authored-by: 2022-blake3-chacha8-poly1305 <139959885+xchacha20-ietf-poly1305@users.noreply.github.com>
This commit is contained in:
HystericalDragon
2023-08-08 14:14:39 +08:00
committed by GitHub
parent d35867b7ab
commit df1c7cc8b4
3 changed files with 11 additions and 11 deletions

View File

@@ -70,12 +70,8 @@ namespace NekoGui_fmt {
outbound->insert("tls", tls); outbound->insert("tls", tls);
} }
if (!packet_encoding.isEmpty()) { if (outbound->value("type").toString() == "vmess" || outbound->value("type").toString() == "vless") {
auto pkt = packet_encoding; outbound->insert("packet_encoding", packet_encoding);
if (pkt == "packet") pkt = "packetaddr";
outbound->insert("packet_encoding", pkt);
} else if (outbound->value("type").toString() == "vless") {
outbound->insert("packet_encoding", "");
} }
} }

View File

@@ -270,11 +270,11 @@ namespace NekoGui_sub {
if (type == "vless") { if (type == "vless") {
bean->flow = Node2QString(proxy["flow"]); bean->flow = Node2QString(proxy["flow"]);
bean->password = Node2QString(proxy["uuid"]); bean->password = Node2QString(proxy["uuid"]);
// meta vless xudp // meta packet encoding
auto xudp = proxy["xudp"]; if (Node2Bool(proxy["packet-addr"])) {
if (xudp.IsDefined() && !xudp.IsNull() && Node2Bool(xudp) == false) { bean->stream->packet_encoding = "packetaddr";
bean->stream->packet_encoding = "";
} else { } else {
// For VLESS, default to use xudp
bean->stream->packet_encoding = "xudp"; bean->stream->packet_encoding = "xudp";
} }
} else { } else {
@@ -323,6 +323,10 @@ namespace NekoGui_sub {
if (Node2Bool(proxy["tls"])) bean->stream->security = "tls"; if (Node2Bool(proxy["tls"])) bean->stream->security = "tls";
if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true; if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true;
// meta packet encoding
if (Node2Bool(proxy["xudp"])) bean->stream->packet_encoding = "xudp";
if (Node2Bool(proxy["packet-addr"])) bean->stream->packet_encoding = "packetaddr";
// opts // opts
auto ws = NodeChild(proxy, {"ws-opts", "ws-opt"}); auto ws = NodeChild(proxy, {"ws-opts", "ws-opt"});
if (ws.IsMap()) { if (ws.IsMap()) {

View File

@@ -271,7 +271,7 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string notr="true">packet</string> <string notr="true">packetaddr</string>
</property> </property>
</item> </item>
<item> <item>