mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 17:48:58 +08:00
feat: 输入增加 Hysteria2 URI 支持; Surge Hysteria2 输出增加 fingerprint
This commit is contained in:
parent
e7c0b23222
commit
bf81ca4acf
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.67",
|
"version": "2.14.68",
|
||||||
"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": {
|
||||||
|
@ -404,6 +404,53 @@ function URI_VLESS() {
|
|||||||
};
|
};
|
||||||
return { name, test, parse };
|
return { name, test, parse };
|
||||||
}
|
}
|
||||||
|
function URI_Hysteria2() {
|
||||||
|
const name = 'URI Hysteria2 Parser';
|
||||||
|
const test = (line) => {
|
||||||
|
return /^hysteria2:\/\//.test(line);
|
||||||
|
};
|
||||||
|
const parse = (line) => {
|
||||||
|
line = line.split('hysteria2://')[1];
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let [__, password, server, ___, port, addons, name] =
|
||||||
|
/^(.*?)@(.*?)(:(\d+))?\/?\?(.*?)(?:#(.*?))$/.exec(line);
|
||||||
|
port = parseInt(`${port}`, 10);
|
||||||
|
if (isNaN(port)) {
|
||||||
|
port = 443;
|
||||||
|
}
|
||||||
|
password = decodeURIComponent(password);
|
||||||
|
name = decodeURIComponent(name) ?? `Hysteria2 ${server}:${port}`;
|
||||||
|
|
||||||
|
const proxy = {
|
||||||
|
type: 'hysteria2',
|
||||||
|
name,
|
||||||
|
server,
|
||||||
|
port,
|
||||||
|
password,
|
||||||
|
};
|
||||||
|
|
||||||
|
const params = {};
|
||||||
|
for (const addon of addons.split('&')) {
|
||||||
|
const [key, valueRaw] = addon.split('=');
|
||||||
|
let value = valueRaw;
|
||||||
|
value = decodeURIComponent(valueRaw);
|
||||||
|
params[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy.sni = params.sni;
|
||||||
|
if (!proxy.sni && params.peer) {
|
||||||
|
proxy.sni = params.peer;
|
||||||
|
}
|
||||||
|
proxy.obfs = params.obfs;
|
||||||
|
proxy['obfs-password'] = params['obfs-password'];
|
||||||
|
proxy['skip-cert-verify'] = /(TRUE)|1/i.test(params.insecure);
|
||||||
|
proxy.tfo = /(TRUE)|1/i.test(params.fastopen);
|
||||||
|
proxy.fingerprint = params.pinSHA256;
|
||||||
|
|
||||||
|
return proxy;
|
||||||
|
};
|
||||||
|
return { name, test, parse };
|
||||||
|
}
|
||||||
|
|
||||||
// Trojan URI format
|
// Trojan URI format
|
||||||
function URI_Trojan() {
|
function URI_Trojan() {
|
||||||
@ -798,6 +845,7 @@ export default [
|
|||||||
URI_SSR(),
|
URI_SSR(),
|
||||||
URI_VMess(),
|
URI_VMess(),
|
||||||
URI_VLESS(),
|
URI_VLESS(),
|
||||||
|
URI_Hysteria2(),
|
||||||
URI_Trojan(),
|
URI_Trojan(),
|
||||||
Clash_All(),
|
Clash_All(),
|
||||||
Surge_SS(),
|
Surge_SS(),
|
||||||
|
@ -367,6 +367,9 @@ function wireguard(proxy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hysteria2(proxy) {
|
function hysteria2(proxy) {
|
||||||
|
if (proxy.obfs || proxy['obfs-password']) {
|
||||||
|
throw new Error(`obfs is unsupported`);
|
||||||
|
}
|
||||||
const result = new Result(proxy);
|
const result = new Result(proxy);
|
||||||
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
||||||
|
|
||||||
@ -388,6 +391,10 @@ function hysteria2(proxy) {
|
|||||||
`,skip-cert-verify=${proxy['skip-cert-verify']}`,
|
`,skip-cert-verify=${proxy['skip-cert-verify']}`,
|
||||||
'skip-cert-verify',
|
'skip-cert-verify',
|
||||||
);
|
);
|
||||||
|
result.appendIfPresent(
|
||||||
|
`,server-cert-fingerprint-sha256=${proxy.fingerprint}`,
|
||||||
|
'fingerprint',
|
||||||
|
);
|
||||||
|
|
||||||
// tfo
|
// tfo
|
||||||
result.appendIfPresent(`,tfo=${proxy['fast-open']}`, 'fast-open');
|
result.appendIfPresent(`,tfo=${proxy['fast-open']}`, 'fast-open');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user