mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-12 19:18:58 +08:00
feat: 支持 AnyTLS URI
This commit is contained in:
parent
c2c39c5de6
commit
f35837ff9f
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.17.1",
|
"version": "2.17.2",
|
||||||
"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": {
|
||||||
|
@ -699,6 +699,52 @@ function URI_VLESS() {
|
|||||||
};
|
};
|
||||||
return { name, test, parse };
|
return { name, test, parse };
|
||||||
}
|
}
|
||||||
|
function URI_AnyTLS() {
|
||||||
|
const name = 'URI AnyTLS Parser';
|
||||||
|
const test = (line) => {
|
||||||
|
return /^anytls:\/\//.test(line);
|
||||||
|
};
|
||||||
|
const parse = (line) => {
|
||||||
|
line = line.split(/anytls:\/\//)[1];
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let [__, password, server, port, addons = '', name] =
|
||||||
|
/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
||||||
|
password = decodeURIComponent(password);
|
||||||
|
port = parseInt(`${port}`, 10);
|
||||||
|
if (isNaN(port)) {
|
||||||
|
port = 443;
|
||||||
|
}
|
||||||
|
password = decodeURIComponent(password);
|
||||||
|
if (name != null) {
|
||||||
|
name = decodeURIComponent(name);
|
||||||
|
}
|
||||||
|
name = name ?? `AnyTLS ${server}:${port}`;
|
||||||
|
|
||||||
|
const proxy = {
|
||||||
|
type: 'anytls',
|
||||||
|
name,
|
||||||
|
server,
|
||||||
|
port,
|
||||||
|
password,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const addon of addons.split('&')) {
|
||||||
|
let [key, value] = addon.split('=');
|
||||||
|
key = key.replace(/_/g, '-');
|
||||||
|
value = decodeURIComponent(value);
|
||||||
|
if (['alpn'].includes(key)) {
|
||||||
|
proxy[key] = value ? value.split(',') : undefined;
|
||||||
|
} else if (['insecure'].includes(key)) {
|
||||||
|
proxy['skip-cert-verify'] = /(TRUE)|1/i.test(value);
|
||||||
|
} else {
|
||||||
|
proxy[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return proxy;
|
||||||
|
};
|
||||||
|
return { name, test, parse };
|
||||||
|
}
|
||||||
function URI_Hysteria2() {
|
function URI_Hysteria2() {
|
||||||
const name = 'URI Hysteria2 Parser';
|
const name = 'URI Hysteria2 Parser';
|
||||||
const test = (line) => {
|
const test = (line) => {
|
||||||
@ -1544,6 +1590,7 @@ export default [
|
|||||||
URI_Hysteria(),
|
URI_Hysteria(),
|
||||||
URI_Hysteria2(),
|
URI_Hysteria2(),
|
||||||
URI_Trojan(),
|
URI_Trojan(),
|
||||||
|
URI_AnyTLS(),
|
||||||
Clash_All(),
|
Clash_All(),
|
||||||
Surge_Direct(),
|
Surge_Direct(),
|
||||||
Surge_SSH(),
|
Surge_SSH(),
|
||||||
|
@ -493,6 +493,7 @@ export default function URI_Producer() {
|
|||||||
'password',
|
'password',
|
||||||
'server',
|
'server',
|
||||||
'port',
|
'port',
|
||||||
|
'tls',
|
||||||
].includes(key)
|
].includes(key)
|
||||||
) {
|
) {
|
||||||
const i = key.replace(/-/, '_');
|
const i = key.replace(/-/, '_');
|
||||||
@ -542,6 +543,50 @@ export default function URI_Producer() {
|
|||||||
)}`;
|
)}`;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'anytls':
|
||||||
|
let anytlsParams = [];
|
||||||
|
Object.keys(proxy).forEach((key) => {
|
||||||
|
if (
|
||||||
|
![
|
||||||
|
'name',
|
||||||
|
'type',
|
||||||
|
'password',
|
||||||
|
'server',
|
||||||
|
'port',
|
||||||
|
'tls',
|
||||||
|
].includes(key)
|
||||||
|
) {
|
||||||
|
const i = key.replace(/-/, '_');
|
||||||
|
if (['alpn'].includes(key)) {
|
||||||
|
if (proxy[key]) {
|
||||||
|
anytlsParams.push(
|
||||||
|
`${i}=${encodeURIComponent(
|
||||||
|
Array.isArray(proxy[key])
|
||||||
|
? proxy[key][0]
|
||||||
|
: proxy[key],
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (['skip-cert-verify'].includes(key)) {
|
||||||
|
if (proxy[key]) {
|
||||||
|
anytlsParams.push(`insecure=1`);
|
||||||
|
}
|
||||||
|
} else if (proxy[key]) {
|
||||||
|
anytlsParams.push(
|
||||||
|
`${i.replace(/-/g, '_')}=${encodeURIComponent(
|
||||||
|
proxy[key],
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
result = `anytls://${encodeURIComponent(proxy.password)}@${
|
||||||
|
proxy.server
|
||||||
|
}:${proxy.port}/?${anytlsParams.join('&')}#${encodeURIComponent(
|
||||||
|
proxy.name,
|
||||||
|
)}`;
|
||||||
|
break;
|
||||||
case 'wireguard':
|
case 'wireguard':
|
||||||
let wireguardParams = [];
|
let wireguardParams = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user