Fix trojan URI issues

This commit is contained in:
Peng-YM 2022-06-20 19:32:57 +08:00
parent e401a31b6c
commit 99946a8795
6 changed files with 19 additions and 39 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.0.8", "version": "2.0.9",
"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

@ -241,15 +241,21 @@ function URI_Trojan() {
const [server, port] = line.split('@')[1].split('?')[0].split(':'); const [server, port] = line.split('@')[1].split('?')[0].split(':');
const name = decodeURIComponent(line.split('#')[1].trim()); const name = decodeURIComponent(line.split('#')[1].trim());
let paramArr = line.split('?'); let paramArr = line.split('?');
let sni = null; let scert = null;
let params;
if (paramArr.length > 1) { if (paramArr.length > 1) {
paramArr = paramArr[1].split('#')[0].split('&'); paramArr = paramArr[1].split('#')[0].split('&');
const params = new Map( params = new Map(
paramArr.map((item) => { paramArr.map((item) => {
return item.split('='); return item.split('=');
}), }),
); );
sni = params.get('sni'); if (
params.get('allowInsecure') === '1' ||
params.get('allowInsecure') === 'true'
) {
scert = true;
}
} }
return { return {
@ -258,7 +264,8 @@ function URI_Trojan() {
server, server,
port, port,
password: line.split('@')[0], password: line.split('@')[0],
sni, sni: getIfPresent(params.get('sni')),
'skip-cert-verify': getIfPresent(scert),
}; };
}; };
return { name, test, parse }; return { name, test, parse };

View File

@ -144,6 +144,11 @@ function trojan(proxy) {
} }
} }
// over tls
if (proxy.network !== 'ws' && needTls(proxy)) {
append(`,over-tls=true`);
}
// tls fingerprint // tls fingerprint
appendIfPresent( appendIfPresent(
`,tls-cert-sha256=${proxy['tls-fingerprint']}`, `,tls-cert-sha256=${proxy['tls-fingerprint']}`,
@ -327,6 +332,7 @@ function needTls(proxy) {
proxy.tls || proxy.tls ||
proxy.sni || proxy.sni ||
typeof proxy['skip-cert-verify'] !== 'undefined' || typeof proxy['skip-cert-verify'] !== 'undefined' ||
typeof proxy['tls-fingerprint'] !== 'undefined' ||
typeof proxy['tls-host'] !== 'undefined' typeof proxy['tls-host'] !== 'undefined'
); );
} }

View File

@ -15,8 +15,7 @@ const { version } = packageJson;
console.log( console.log(
` `
𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 © 𝑷𝒆𝒏𝒈-𝒀𝑴 Sub-Store © Peng-YM -- v${version}
Version: ${version}
`, `,
); );

File diff suppressed because one or more lines are too long