fix: transport headers may have no Host

This commit is contained in:
xream 2023-08-27 18:17:30 +08:00
parent 8bfa4dbbf2
commit 49c7107d20
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 8 additions and 8 deletions

View File

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

View File

@ -101,7 +101,7 @@ function trojan(proxy) {
'ws-opts.path',
);
result.appendIfPresent(
`,host=${proxy['ws-opts'].headers.Host}`,
`,host=${proxy['ws-opts']?.headers?.Host}`,
'ws-opts.headers.Host',
);
} else {
@ -138,11 +138,11 @@ function vmess(proxy) {
if (proxy.network === 'ws') {
result.append(`,transport=ws`);
result.appendIfPresent(
`,path=${proxy['ws-opts'].path}`,
`,path=${proxy['ws-opts']?.path}`,
'ws-opts.path',
);
result.appendIfPresent(
`,host=${proxy['ws-opts'].headers.Host}`,
`,host=${proxy['ws-opts']?.headers?.Host}`,
'ws-opts.headers.Host',
);
} else if (proxy.network === 'http') {
@ -205,11 +205,11 @@ function vless(proxy) {
if (proxy.network === 'ws') {
result.append(`,transport=ws`);
result.appendIfPresent(
`,path=${proxy['ws-opts'].path}`,
`,path=${proxy['ws-opts']?.path}`,
'ws-opts.path',
);
result.appendIfPresent(
`,host=${proxy['ws-opts'].headers.Host}`,
`,host=${proxy['ws-opts']?.headers?.Host}`,
'ws-opts.headers.Host',
);
} else if (proxy.network === 'http') {

View File

@ -135,11 +135,11 @@ function trojan(proxy) {
if (needTls(proxy)) append(`,obfs=wss`);
else append(`,obfs=ws`);
appendIfPresent(
`,obfs-uri=${proxy['ws-opts'].path}`,
`,obfs-uri=${proxy['ws-opts']?.path}`,
'ws-opts.path',
);
appendIfPresent(
`,obfs-host=${proxy['ws-opts'].headers.Host}`,
`,obfs-host=${proxy['ws-opts']?.headers?.Host}`,
'ws-opts.headers.Host',
);
} else {