mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-12 14:06:58 +08:00
Fix trojan URI issues
This commit is contained in:
@@ -241,15 +241,21 @@ function URI_Trojan() {
|
||||
const [server, port] = line.split('@')[1].split('?')[0].split(':');
|
||||
const name = decodeURIComponent(line.split('#')[1].trim());
|
||||
let paramArr = line.split('?');
|
||||
let sni = null;
|
||||
let scert = null;
|
||||
let params;
|
||||
if (paramArr.length > 1) {
|
||||
paramArr = paramArr[1].split('#')[0].split('&');
|
||||
const params = new Map(
|
||||
params = new Map(
|
||||
paramArr.map((item) => {
|
||||
return item.split('=');
|
||||
}),
|
||||
);
|
||||
sni = params.get('sni');
|
||||
if (
|
||||
params.get('allowInsecure') === '1' ||
|
||||
params.get('allowInsecure') === 'true'
|
||||
) {
|
||||
scert = true;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -258,7 +264,8 @@ function URI_Trojan() {
|
||||
server,
|
||||
port,
|
||||
password: line.split('@')[0],
|
||||
sni,
|
||||
sni: getIfPresent(params.get('sni')),
|
||||
'skip-cert-verify': getIfPresent(scert),
|
||||
};
|
||||
};
|
||||
return { name, test, parse };
|
||||
|
||||
@@ -144,6 +144,11 @@ function trojan(proxy) {
|
||||
}
|
||||
}
|
||||
|
||||
// over tls
|
||||
if (proxy.network !== 'ws' && needTls(proxy)) {
|
||||
append(`,over-tls=true`);
|
||||
}
|
||||
|
||||
// tls fingerprint
|
||||
appendIfPresent(
|
||||
`,tls-cert-sha256=${proxy['tls-fingerprint']}`,
|
||||
@@ -327,6 +332,7 @@ function needTls(proxy) {
|
||||
proxy.tls ||
|
||||
proxy.sni ||
|
||||
typeof proxy['skip-cert-verify'] !== 'undefined' ||
|
||||
typeof proxy['tls-fingerprint'] !== 'undefined' ||
|
||||
typeof proxy['tls-host'] !== 'undefined'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user