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", "name": "sub-store",
"version": "2.14.31", "version": "2.14.32",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

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

View File

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