Merge pull request #663: preserve VMess h2 host lists

This commit is contained in:
Codex committed 2026-10-25 09:52:28 +08:00
commit 1613ea5b2c
2 files changed
+31 -1

No files matched your search

@@ -1139,8 +1139,12 @@ export default function URI_Producer() {
result.path = vmessTransportPath;
}
if (vmessTransportHost) {
// h2 takes a comma-separated host list, which the
// VMess URI parser splits into h2-opts.host
result.host = Array.isArray(vmessTransportHost)
? vmessTransportHost[0]
? proxy.network === 'h2'
? vmessTransportHost.join(',')
: vmessTransportHost[0]
: vmessTransportHost;
}
}
@@ -5834,6 +5834,32 @@ describe('Proxy text producers', function () {
});
}
it('keeps every h2 host in URI VMess links', function () {
const output = produceExternal('URI', {
type: 'vmess',
name: 'URI VMess H2',
server: 'vmess.example.com',
port: 443,
uuid: UUID,
alterId: 0,
cipher: 'auto',
tls: true,
network: 'h2',
'h2-opts': {
path: '/h2',
host: ['a.example.com', 'b.example.com'],
},
});
const json = JSON.parse(Base64.decode(output.replace('vmess://', '')));
expect(json.host).to.equal('a.example.com,b.example.com');
const [parsed] = ProxyUtils.parse(output);
expect(parsed['h2-opts'].host).to.deep.equal([
'a.example.com',
'b.example.com',
]);
});
it('produces URI Trojan links with vcn from the sidecar', function () {
const output = produceExternal('URI', {
type: 'trojan',