fix: vmess/vless http-opts.path/http-opts.headers.Host must be an array in some clients

This commit is contained in:
xream 2023-08-21 22:16:07 +08:00
parent 9e54507bbb
commit 99b19c410d
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
5 changed files with 53 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.14",
"version": "2.14.15",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {

View File

@ -55,6 +55,26 @@ export default function Clash_Producer() {
}
}
if (
['vmess', 'vless'].includes(proxy.type) &&
proxy.network === 'http'
) {
let httpPath = proxy['http-opts']?.path;
if (
isPresent(proxy, 'http-opts.path') &&
!Array.isArray(httpPath)
) {
proxy['http-opts'].path = [httpPath];
}
let httpHost = proxy['http-opts']?.headers?.Host;
if (
isPresent(proxy, 'http-opts.headers.Host') &&
!Array.isArray(httpHost)
) {
proxy['http-opts'].headers.Host = [httpHost];
}
}
delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n';
})

View File

@ -144,12 +144,14 @@ function vmess(proxy) {
);
} else if (proxy.network === 'http') {
result.append(`,transport=http`);
let httpPath = proxy['http-opts']?.path;
let httpHost = proxy['http-opts']?.headers?.Host;
result.appendIfPresent(
`,path=${proxy['http-opts'].path}`,
`,path=${Array.isArray(httpPath) ? httpPath[0] : httpPath}`,
'http-opts.path',
);
result.appendIfPresent(
`,host=${proxy['http-opts'].headers.Host}`,
`,host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
'http-opts.headers.Host',
);
} else {
@ -206,12 +208,14 @@ function vless(proxy) {
);
} else if (proxy.network === 'http') {
result.append(`,transport=http`);
let httpPath = proxy['http-opts']?.path;
let httpHost = proxy['http-opts']?.headers?.Host;
result.appendIfPresent(
`,path=${proxy['http-opts'].path}`,
`,path=${Array.isArray(httpPath) ? httpPath[0] : httpPath}`,
'http-opts.path',
);
result.appendIfPresent(
`,host=${proxy['http-opts'].headers.Host}`,
`,host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
'http-opts.headers.Host',
);
} else {

View File

@ -206,12 +206,14 @@ function vmess(proxy) {
} else {
throw new Error(`network ${proxy.network} is unsupported`);
}
let httpPath = proxy[`${proxy.network}-opts`]?.path;
let httpHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
appendIfPresent(
`,obfs-uri=${proxy[`${proxy.network}-opts`].path}`,
`,obfs-uri=${Array.isArray(httpPath) ? httpPath[0] : httpPath}`,
`${proxy.network}-opts.path`,
);
appendIfPresent(
`,obfs-host=${proxy[`${proxy.network}-opts`].headers.Host}`,
`,obfs-host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
`${proxy.network}-opts.headers.Host`,
);
} else {

View File

@ -58,6 +58,26 @@ export default function Stash_Producer() {
}
}
if (
['vmess', 'vless'].includes(proxy.type) &&
proxy.network === 'http'
) {
let httpPath = proxy['http-opts']?.path;
if (
isPresent(proxy, 'http-opts.path') &&
!Array.isArray(httpPath)
) {
proxy['http-opts'].path = [httpPath];
}
let httpHost = proxy['http-opts']?.headers?.Host;
if (
isPresent(proxy, 'http-opts.headers.Host') &&
!Array.isArray(httpHost)
) {
proxy['http-opts'].headers.Host = [httpHost];
}
}
delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n';
})