fix(vmess): keep all h2 hosts in the URI

The VMess URI parser splits a comma-separated h2 host into h2-opts.host,
but the producer only wrote the first entry back, so a node with several
h2 hosts lost the others on every URI export.
This commit is contained in:
Pharex38 committed 2026-10-24 19:01:36 +03:00
1 parent a6d09c7aaa
commit 9404971feb
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;
}
}
@@ -5777,6 +5777,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',