mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa65eb1850 | ||
|
|
79c9b89c5f | ||
|
|
fca508ba8a | ||
|
|
21b531a44d | ||
|
|
4e5b46a43d | ||
|
|
bf81ca4acf | ||
|
|
e7c0b23222 | ||
|
|
40fb0fd7f3 | ||
|
|
b061fca356 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.63",
|
||||
"version": "2.14.73",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -240,7 +240,7 @@ function URI_VMess() {
|
||||
params.add = server;
|
||||
}
|
||||
const proxy = {
|
||||
name: params.ps ?? params.remark,
|
||||
name: params.ps ?? params.remarks,
|
||||
type: 'vmess',
|
||||
server: params.add,
|
||||
port: parseInt(getIfPresent(params.port), 10),
|
||||
@@ -272,6 +272,14 @@ function URI_VMess() {
|
||||
}
|
||||
if (proxy.network) {
|
||||
let transportHost = params.host ?? params.obfsParam;
|
||||
try {
|
||||
const parsedObfs = JSON.parse(transportHost);
|
||||
const parsedHost = parsedObfs?.Host;
|
||||
if (parsedHost) {
|
||||
transportHost = parsedHost;
|
||||
}
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (e) {}
|
||||
let transportPath = params.path;
|
||||
|
||||
if (proxy.network === 'http') {
|
||||
@@ -396,6 +404,53 @@ function URI_VLESS() {
|
||||
};
|
||||
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
|
||||
function URI_Trojan() {
|
||||
@@ -776,11 +831,21 @@ function Surge_WireGuard() {
|
||||
return { name, test, parse };
|
||||
}
|
||||
|
||||
function Surge_Hysteria2() {
|
||||
const name = 'Surge Hysteria2 Parser';
|
||||
const test = (line) => {
|
||||
return /^.*=\s*hysteria2/.test(line.split(',')[0]);
|
||||
};
|
||||
const parse = (line) => getSurgeParser().parse(line);
|
||||
return { name, test, parse };
|
||||
}
|
||||
|
||||
export default [
|
||||
URI_SS(),
|
||||
URI_SSR(),
|
||||
URI_VMess(),
|
||||
URI_VLESS(),
|
||||
URI_Hysteria2(),
|
||||
URI_Trojan(),
|
||||
Clash_All(),
|
||||
Surge_SS(),
|
||||
@@ -790,6 +855,7 @@ export default [
|
||||
Surge_Snell(),
|
||||
Surge_Tuic(),
|
||||
Surge_WireGuard(),
|
||||
Surge_Hysteria2(),
|
||||
Surge_Socks5(),
|
||||
Loon_SS(),
|
||||
Loon_SSR(),
|
||||
|
||||
@@ -32,7 +32,7 @@ const grammars = String.raw`
|
||||
}
|
||||
}
|
||||
|
||||
start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard) {
|
||||
start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ https = tag equals "https" address (username password)? (sni/tls_fingerprint/tls
|
||||
http = tag equals "http" address (username password)? (fast_open/others)* {
|
||||
proxy.type = "http";
|
||||
}
|
||||
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/fast_open/udp_relay/others)* {
|
||||
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/fast_open/udp_relay/reuse/others)* {
|
||||
proxy.type = "snell";
|
||||
// handle obfs
|
||||
if (obfs.type == "http" || obfs.type === "tls") {
|
||||
@@ -76,16 +76,19 @@ snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_
|
||||
$set(proxy, "obfs-opts.path", obfs.path);
|
||||
}
|
||||
}
|
||||
tuic = tag equals "tuic" address (alpn/token/ip_version/tls_verification/sni/fast_open/tfo/others)* {
|
||||
tuic = tag equals "tuic" address (alpn/token/ip_version/tls_verification/sni/fast_open/tfo/ecn/others)* {
|
||||
proxy.type = "tuic";
|
||||
}
|
||||
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/tls_verification/sni/fast_open/tfo/others)* {
|
||||
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/tls_verification/sni/fast_open/tfo/ecn/others)* {
|
||||
proxy.type = "tuic";
|
||||
proxy.version = 5;
|
||||
}
|
||||
wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/test_url/others)* {
|
||||
proxy.type = "wireguard-surge";
|
||||
}
|
||||
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/test_url/sni/tls_verification/passwordk/download_bandwidth/ecn/others)* {
|
||||
proxy.type = "hysteria2";
|
||||
}
|
||||
socks5 = tag equals "socks5" address (username password)? (fast_open/others)* {
|
||||
proxy.type = "socks5";
|
||||
}
|
||||
@@ -188,11 +191,14 @@ uri = $[^,]+
|
||||
|
||||
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
||||
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
||||
reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; }
|
||||
ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; }
|
||||
tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; }
|
||||
ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
||||
section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); }
|
||||
no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); }
|
||||
underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); }
|
||||
download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); }
|
||||
test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); }
|
||||
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
||||
alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard) {
|
||||
start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ https = tag equals "https" address (username password)? (sni/tls_fingerprint/tls
|
||||
http = tag equals "http" address (username password)? (fast_open/others)* {
|
||||
proxy.type = "http";
|
||||
}
|
||||
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/fast_open/udp_relay/others)* {
|
||||
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/fast_open/udp_relay/reuse/others)* {
|
||||
proxy.type = "snell";
|
||||
// handle obfs
|
||||
if (obfs.type == "http" || obfs.type === "tls") {
|
||||
@@ -74,16 +74,19 @@ snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_
|
||||
$set(proxy, "obfs-opts.path", obfs.path);
|
||||
}
|
||||
}
|
||||
tuic = tag equals "tuic" address (alpn/token/ip_version/tls_verification/sni/fast_open/tfo/others)* {
|
||||
tuic = tag equals "tuic" address (alpn/token/ip_version/tls_verification/sni/fast_open/tfo/ecn/others)* {
|
||||
proxy.type = "tuic";
|
||||
}
|
||||
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/tls_verification/sni/fast_open/tfo/others)* {
|
||||
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/tls_verification/sni/fast_open/tfo/ecn/others)* {
|
||||
proxy.type = "tuic";
|
||||
proxy.version = 5;
|
||||
}
|
||||
wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/test_url/others)* {
|
||||
proxy.type = "wireguard-surge";
|
||||
}
|
||||
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/test_url/sni/tls_verification/passwordk/download_bandwidth/ecn/others)* {
|
||||
proxy.type = "hysteria2";
|
||||
}
|
||||
socks5 = tag equals "socks5" address (username password)? (fast_open/others)* {
|
||||
proxy.type = "socks5";
|
||||
}
|
||||
@@ -186,11 +189,14 @@ uri = $[^,]+
|
||||
|
||||
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
||||
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
||||
reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; }
|
||||
ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; }
|
||||
tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; }
|
||||
ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
||||
section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); }
|
||||
no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); }
|
||||
underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); }
|
||||
download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); }
|
||||
test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); }
|
||||
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
||||
alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
|
||||
|
||||
@@ -13,13 +13,15 @@ function Base64Encoded() {
|
||||
const name = 'Base64 Pre-processor';
|
||||
|
||||
const keys = [
|
||||
'dm1lc3M',
|
||||
'c3NyOi8v',
|
||||
'dHJvamFu',
|
||||
'c3M6Ly',
|
||||
'c3NkOi8v',
|
||||
'c2hhZG93',
|
||||
'aHR0c',
|
||||
'dm1lc3M', // vmess
|
||||
'c3NyOi8v', // ssr://
|
||||
'dHJvamFu', // trojan
|
||||
'c3M6Ly', // ss:/
|
||||
'c3NkOi8v', // ssd://
|
||||
'c2hhZG93', // shadow
|
||||
'aHR0c', // htt
|
||||
'dmxlc3M=', // vless
|
||||
'aHlzdGVyaWEy', // hysteria2
|
||||
];
|
||||
|
||||
const test = function (raw) {
|
||||
|
||||
@@ -19,6 +19,8 @@ export default function Stash_Producer() {
|
||||
'tuic',
|
||||
'vless',
|
||||
'wireguard',
|
||||
'hysteria',
|
||||
'hysteria2',
|
||||
].includes(proxy.type) ||
|
||||
(proxy.type === 'snell' &&
|
||||
String(proxy.version) === '4') ||
|
||||
@@ -67,6 +69,7 @@ export default function Stash_Producer() {
|
||||
!isPresent(proxy, 'fast-open')
|
||||
) {
|
||||
proxy['fast-open'] = proxy.tfo;
|
||||
delete proxy.tfo;
|
||||
}
|
||||
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197
|
||||
if (
|
||||
@@ -86,6 +89,50 @@ export default function Stash_Producer() {
|
||||
!isPresent(proxy, 'fast-open')
|
||||
) {
|
||||
proxy['fast-open'] = proxy.tfo;
|
||||
delete proxy.tfo;
|
||||
}
|
||||
if (
|
||||
isPresent(proxy, 'down') &&
|
||||
!isPresent(proxy, 'down-speed')
|
||||
) {
|
||||
proxy['down-speed'] = proxy.down;
|
||||
delete proxy.down;
|
||||
}
|
||||
if (
|
||||
isPresent(proxy, 'up') &&
|
||||
!isPresent(proxy, 'up-speed')
|
||||
) {
|
||||
proxy['up-speed'] = proxy.up;
|
||||
delete proxy.up;
|
||||
}
|
||||
} else if (proxy.type === 'hysteria2') {
|
||||
if (
|
||||
isPresent(proxy, 'password') &&
|
||||
!isPresent(proxy, 'auth')
|
||||
) {
|
||||
proxy.auth = proxy.password;
|
||||
delete proxy.password;
|
||||
}
|
||||
if (
|
||||
isPresent(proxy, 'tfo') &&
|
||||
!isPresent(proxy, 'fast-open')
|
||||
) {
|
||||
proxy['fast-open'] = proxy.tfo;
|
||||
delete proxy.tfo;
|
||||
}
|
||||
if (
|
||||
isPresent(proxy, 'down') &&
|
||||
!isPresent(proxy, 'down-speed')
|
||||
) {
|
||||
proxy['down-speed'] = proxy.down;
|
||||
delete proxy.down;
|
||||
}
|
||||
if (
|
||||
isPresent(proxy, 'up') &&
|
||||
!isPresent(proxy, 'up-speed')
|
||||
) {
|
||||
proxy['up-speed'] = proxy.up;
|
||||
delete proxy.up;
|
||||
}
|
||||
} else if (proxy.type === 'wireguard') {
|
||||
proxy.keepalive =
|
||||
|
||||
@@ -31,6 +31,8 @@ export default function Surge_Producer() {
|
||||
return tuic(proxy);
|
||||
case 'wireguard-surge':
|
||||
return wireguard(proxy);
|
||||
case 'hysteria2':
|
||||
return hysteria2(proxy);
|
||||
}
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
@@ -330,6 +332,8 @@ function tuic(proxy) {
|
||||
'underlying-proxy',
|
||||
);
|
||||
|
||||
result.appendIfPresent(`,ecn=${proxy.ecn}`, 'ecn');
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@@ -364,6 +368,60 @@ function wireguard(proxy) {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
function hysteria2(proxy) {
|
||||
if (proxy.obfs || proxy['obfs-password']) {
|
||||
throw new Error(`obfs is unsupported`);
|
||||
}
|
||||
const result = new Result(proxy);
|
||||
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
||||
|
||||
result.appendIfPresent(`,password=${proxy.password}`, 'password');
|
||||
|
||||
result.appendIfPresent(
|
||||
`,ip-version=${ipVersions[proxy['ip-version']] || proxy['ip-version']}`,
|
||||
'ip-version',
|
||||
);
|
||||
|
||||
result.appendIfPresent(
|
||||
`,no-error-alert=${proxy['no-error-alert']}`,
|
||||
'no-error-alert',
|
||||
);
|
||||
|
||||
// tls verification
|
||||
result.appendIfPresent(`,sni=${proxy.sni}`, 'sni');
|
||||
result.appendIfPresent(
|
||||
`,skip-cert-verify=${proxy['skip-cert-verify']}`,
|
||||
'skip-cert-verify',
|
||||
);
|
||||
result.appendIfPresent(
|
||||
`,server-cert-fingerprint-sha256=${proxy.fingerprint}`,
|
||||
'fingerprint',
|
||||
);
|
||||
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy['fast-open']}`, 'fast-open');
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
|
||||
// underlying-proxy
|
||||
result.appendIfPresent(
|
||||
`,underlying-proxy=${proxy['underlying-proxy']}`,
|
||||
'underlying-proxy',
|
||||
);
|
||||
|
||||
// download-bandwidth
|
||||
result.appendIfPresent(
|
||||
`,download-bandwidth=${`${proxy['down']}`.match(/\d+/)?.[0] || 0}`,
|
||||
'down',
|
||||
);
|
||||
|
||||
result.appendIfPresent(`,ecn=${proxy.ecn}`, 'ecn');
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
function handleTransport(result, proxy) {
|
||||
if (isPresent(proxy, 'network')) {
|
||||
if (proxy.network === 'ws') {
|
||||
|
||||
Reference in New Issue
Block a user