mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-30 09:45:00 +03:00
fix(finalmask): hop client UDP through the udphop mask
xray-core 26.9.9 dropped finalmask.quicParams.udpHop for the client-only
"udphop" UDP mask {mode, interval, remoteIPs, remotePorts}. The panel kept
writing the old key, so hysteria/xhttp outbounds and JSON-subscription
clients silently stopped hopping ports.
An inbound keeps quicParams.udpHop: it is panel metadata advertised as the
link's mport, and a udphop mask on a listener fails with "udphop: client
only". The conversion (maskcompat.UpgradeLegacyUDPHop, intervalRemote mode)
runs only where a client config is produced:
- UDPHopClientMaskFix seeder over hosts, sub-JSON finalmask, cached
outbound-subscription outbounds and template outbounds (never inbounds);
- GetXrayConfig heals template outbounds at build time;
- the JSON subscription upgrades each generated client stream;
- the Go and frontend link importers upgrade a legacy fm= param.
The finalmask editor gains a side prop: the client side lifts the dead key
on mount and offers a udphop mask editor (also for xhttp's HTTP/3 dial);
the inbound side keeps the UDP Hop switch, labelled as advertised.
This commit is contained in:
@@ -769,6 +769,7 @@ func applyFinalMask(stream map[string]any, p url.Values) {
|
||||
if json.Unmarshal([]byte(fm), &parsed) == nil {
|
||||
sanitizeFinalMaskQuicParams(parsed)
|
||||
maskcompat.UpgradeLegacyXdns(parsed)
|
||||
maskcompat.UpgradeLegacyUDPHop(parsed)
|
||||
stream["finalmask"] = parsed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,9 +304,9 @@ func TestParseHysteria2_Mport(t *testing.T) {
|
||||
wantHop: true,
|
||||
},
|
||||
{
|
||||
name: "legacy fm quicParams.udpHop no longer suppresses mport",
|
||||
name: "legacy fm quicParams.udpHop is upgraded and wins over mport like the mask",
|
||||
query: "mport=1-2&fm=" + url.QueryEscape(`{"quicParams":{"udpHop":{"ports":"30000-40000","interval":"7-9"}}}`),
|
||||
wantPorts: "1-2",
|
||||
wantPorts: "30000-40000",
|
||||
wantHop: true,
|
||||
},
|
||||
}
|
||||
@@ -577,3 +577,22 @@ func TestParseShadowsocksObfsLocalPlugin(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A panel older than the 26.9.9 core shares its hop range as quicParams.udpHop inside fm=,
|
||||
// which the core ignores; imported verbatim, the outbound would never hop.
|
||||
func TestParseLink_UpgradesLegacyUDPHopFinalMask(t *testing.T) {
|
||||
fm := url.QueryEscape(`{"quicParams":{"udpHop":{"ports":"20000-30000","interval":"5-10"}}}`)
|
||||
res, err := ParseLink("hysteria2://auth@hy.example.com:443?sni=hy.example.com&fm=" + fm + "#hy")
|
||||
if err != nil {
|
||||
t.Fatalf("parse hysteria2 with fm: %v", err)
|
||||
}
|
||||
stream, _ := res.Outbound["streamSettings"].(map[string]any)
|
||||
got, err := json.Marshal(stream["finalmask"])
|
||||
if err != nil {
|
||||
t.Fatalf("marshal finalmask: %v", err)
|
||||
}
|
||||
want := `{"udp":[{"settings":{"interval":"5-10","mode":"intervalRemote","remotePorts":"20000-30000"},"type":"udphop"}]}`
|
||||
if string(got) != want {
|
||||
t.Fatalf("imported finalmask\n got: %s\nwant: %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user