fix(outbound): fill encryption and pqv when importing VLESS link

The link-to-JSON importer dropped two VLESS Reality fields:

- pqv (post-quantum ML-DSA-65 verify key) was never parsed; map it back
  to realitySettings.mldsa65Verify, matching the inbound link generator.
- encryption was force-reset to 'none' in the form adapter regardless of
  the parsed value, discarding post-quantum encryption strings.

Add regression tests for both paths.
This commit is contained in:
MHSanaei committed 2026-06-01 17:37:54 +02:00 Unverified
1 parent 28330e60d8
commit 13c04bb982
4 files changed
+38 -1

No files matched your search

@@ -123,7 +123,7 @@ function vlessFromWire(raw: Raw): VlessOutboundFormSettings {
port,
id,
flow,
encryption: (encryption === 'none' ? 'none' : 'none') as 'none',
encryption: encryption || 'none',
reverseTag,
reverseSniffing,
testpre: asNumber(raw.testpre, 0),
@@ -210,6 +210,7 @@ function applySecurityParams(stream: Raw, params: URLSearchParams): void {
reality.publicKey = params.get('pbk') ?? '';
reality.shortId = params.get('sid') ?? '';
reality.spiderX = params.get('spx') ?? '';
reality.mldsa65Verify = params.get('pqv') ?? '';
}
}
@@ -74,6 +74,25 @@ describe('outbound-form-adapter: round-trip', () => {
});
});
it('vless preserves a non-none encryption value (post-quantum)', () => {
const enc = 'mlkem768x25519plus.native.0rtt.G3cdPSd1-NnlpTbWNSM5vHsT5VNzWfFzYSKwbUMnV1Y';
const wire = {
protocol: 'vless',
settings: {
address: 'srv',
port: 443,
id: '11111111-2222-4333-8444-555555555555',
flow: '',
encryption: enc,
},
};
const form = rawOutboundToFormValues(wire);
if (form.protocol === 'vless') {
expect(form.settings.encryption).toBe(enc);
}
expect((formValuesToWirePayload(form).settings as Record<string, unknown>).encryption).toBe(enc);
});
it('vless emits reverse + sniffing when reverseTag is set', () => {
const wire = {
protocol: 'vless',
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff. Show more