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:
MHSanaei
2026-10-11 11:20:34 +02:00
parent 00aaef386f
commit ec0a57fc4f
22 changed files with 797 additions and 51 deletions
+27 -2
View File
@@ -488,6 +488,25 @@ describe('parseShadowsocksLink', () => {
});
describe('parseHysteria2Link', () => {
// A panel older than the 26.9.9 core shares its hop range as quicParams.udpHop in fm=,
// which the core ignores; the import must hand it the udphop mask instead.
it('upgrades a legacy fm= quicParams.udpHop to the udphop mask', () => {
const fm = encodeURIComponent(
JSON.stringify({ quicParams: { udpHop: { ports: '20000-30000', interval: '5-10' } } }),
);
const out = parseHysteria2Link(
`hysteria2://auth@hy.example.com:443?sni=hy.example.com&fm=${fm}#hy`,
);
expect((out!.streamSettings as Record<string, unknown>).finalmask).toEqual({
udp: [
{
type: 'udphop',
settings: { mode: 'intervalRemote', remotePorts: '20000-30000', interval: '5-10' },
},
],
});
});
it('parses a hysteria2:// link with sni', () => {
const link = 'hysteria2://auth-secret@srv.example:443?sni=example.com#imported-hy2';
const out = parseHysteria2Link(link);
@@ -822,8 +841,14 @@ describe('parseVlessLink — extra / fm / x_padding_bytes (B20)', () => {
const quicParams = finalmask.quicParams as Record<string, unknown>;
expect(quicParams.congestion).toBe('bbr');
expect(quicParams.maxIdleTimeout).toBe(30);
expect((quicParams.udpHop as Record<string, unknown>).interval).toBe('5-10');
expect((quicParams.udpHop as Record<string, unknown>).ports).toBe('20000-50000');
// xray-core 26.9.9 ignores quicParams.udpHop; the import moves it to the udphop mask.
expect(quicParams.udpHop).toBeUndefined();
expect(finalmask.udp).toEqual([
{
type: 'udphop',
settings: { mode: 'intervalRemote', remotePorts: '20000-50000', interval: '5-10' },
},
]);
});
it('falls back to x_padding_bytes when extra has no xPaddingBytes', () => {