Compare commits

...

9 Commits

Author SHA1 Message Date
xream
ad3d2270ac feat: 读取节点的 ca-str 和 _ca (后端文件路径) 字段, 自动计算 fingerprint 2024-06-13 20:44:12 +08:00
xream
3ad42f2c10 feat: Stash 支持 juicity, ssh 2024-06-12 15:16:56 +08:00
xream
ec06eb8659 fix: sing-box tls cert 应该为数组 2024-06-10 19:10:57 +08:00
xream
4a23a4d8b6 fix: tlsParser typo 2024-06-10 19:07:19 +08:00
xream
913638a233 feat: /api/sub/flow/:name 接口支持指定远程订阅 url(可携带订阅 url 支持的参数, 例如 flowUserAgent) 2024-06-10 13:24:06 +08:00
xream
bf642ce0e6 fix: 兼容空的订阅链接 2024-06-09 01:42:40 +08:00
xream
1ecac9da92 chore: demo.js 2024-06-06 21:50:13 +08:00
xream
c5a417da8f feat: VMess URI 支持 TCP/H2 传输层 2024-06-03 21:14:07 +08:00
xream
8cd0545023 feat: ws, http, h2 传输层补全 path 2024-06-03 00:34:03 +08:00
17 changed files with 136 additions and 36 deletions

View File

@@ -35,7 +35,7 @@ Core functionalities:
- [x] Surfboard (SS, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, WireGuard(Surfboard to Surfboard))
- [x] Shadowrocket (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, Hysteria 2, TUIC)
- [x] Clash.Meta (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, Hysteria 2, TUIC)
- [x] Stash (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, TUIC)
- [x] Stash (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, TUIC, Juicity, SSH)
- [x] Clash (SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard)
### Supported Target Platforms

View File

@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.331",
"version": "2.14.339",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
@@ -25,6 +25,7 @@
"express": "^4.17.1",
"http-proxy-middleware": "^2.0.6",
"js-base64": "^3.7.2",
"jsrsasign": "^11.1.0",
"lodash": "^4.17.21",
"request": "^2.88.2",
"requests": "^0.3.0",

View File

@@ -29,6 +29,9 @@ dependencies:
js-base64:
specifier: ^3.7.2
version: registry.npmmirror.com/js-base64@3.7.2
jsrsasign:
specifier: ^11.1.0
version: registry.npmmirror.com/jsrsasign@11.1.0
lodash:
specifier: ^4.17.21
version: registry.npmmirror.com/lodash@4.17.21
@@ -6634,6 +6637,12 @@ packages:
verror: registry.npmmirror.com/verror@1.10.0
dev: false
registry.npmmirror.com/jsrsasign@11.1.0:
resolution: {integrity: sha512-Ov74K9GihaK9/9WncTe1mPmvrO7Py665TUfUKvraXBpu+xcTWitrtuOwcjf4KMU9maPaYn0OuaWy0HOzy/GBXg==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/jsrsasign/-/jsrsasign-11.1.0.tgz}
name: jsrsasign
version: 11.1.0
dev: false
registry.npmmirror.com/just-debounce@1.1.0:
resolution: {integrity: sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/just-debounce/-/just-debounce-1.1.0.tgz}
name: just-debounce

View File

@@ -1,3 +1,4 @@
import rs from '@/utils/rs';
import YAML from '@/utils/yaml';
import download from '@/utils/download';
import {
@@ -83,7 +84,7 @@ async function processFn(proxies, operators = [], targetPlatform, source) {
const { mode, content } = item.args;
if (mode === 'link') {
let noCache;
let url = content;
let url = content || '';
if (url.endsWith('#noCache')) {
url = url.replace(/#noCache$/, '');
noCache = true;
@@ -338,7 +339,11 @@ function lastParse(proxy) {
proxy.network = 'tcp';
}
}
if (['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(proxy.type)) {
if (
['trojan', 'tuic', 'hysteria', 'hysteria2', 'juicity'].includes(
proxy.type,
)
) {
proxy.tls = true;
}
if (proxy.network) {
@@ -438,9 +443,46 @@ function lastParse(proxy) {
}
}
}
if (['ws', 'http', 'h2'].includes(proxy.network)) {
if (
['ws', 'h2'].includes(proxy.network) &&
!proxy[`${proxy.network}-opts`]?.path
) {
proxy[`${proxy.network}-opts`] =
proxy[`${proxy.network}-opts`] || {};
proxy[`${proxy.network}-opts`].path = '/';
} else if (
proxy.network === 'http' &&
(!Array.isArray(proxy[`${proxy.network}-opts`]?.path) ||
proxy[`${proxy.network}-opts`]?.path.every((i) => !i))
) {
proxy[`${proxy.network}-opts`] =
proxy[`${proxy.network}-opts`] || {};
proxy[`${proxy.network}-opts`].path = ['/'];
}
}
if (['', 'off'].includes(proxy.sni)) {
proxy['disable-sni'] = true;
}
let caStr = proxy['ca_str'];
if (proxy['ca-str']) {
caStr = proxy['ca-str'];
} else if (caStr) {
delete proxy['ca_str'];
proxy['ca-str'] = caStr;
}
try {
if ($.env.isNode && !caStr && proxy['_ca']) {
caStr = $.node.fs.readFileSync(proxy['_ca'], {
encoding: 'utf8',
});
}
} catch (e) {
$.error(`Read ca file failed\nReason: ${e}`);
}
if (!proxy['tls-fingerprint'] && caStr) {
proxy['tls-fingerprint'] = rs.generateFingerprint(caStr);
}
return proxy;
}

View File

@@ -305,8 +305,9 @@ function URI_VMess() {
if (params.net === 'ws' || params.obfs === 'websocket') {
proxy.network = 'ws';
} else if (
['tcp', 'http'].includes(params.net) ||
params.obfs === 'http'
['http'].includes(params.net) ||
['http'].includes(params.obfs) ||
['http'].includes(params.type)
) {
proxy.network = 'http';
} else if (['grpc'].includes(params.net)) {
@@ -317,6 +318,8 @@ function URI_VMess() {
) {
proxy.network = 'ws';
httpupgrade = true;
} else if (params.net === 'h2' || proxy.network === 'h2') {
proxy.network = 'h2';
}
if (proxy.network) {
let transportHost = params.host ?? params.obfsParam;
@@ -332,6 +335,10 @@ function URI_VMess() {
if (proxy.network === 'http') {
if (transportHost) {
// 1)http(tcp)->host中间逗号(,)隔开
transportHost = transportHost
.split(',')
.map((i) => i.trim());
transportHost = Array.isArray(transportHost)
? transportHost[0]
: transportHost;

View File

@@ -133,9 +133,13 @@ export default function Clash_Producer() {
}
}
if (
['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(
proxy.type,
)
[
'trojan',
'tuic',
'hysteria',
'hysteria2',
'juicity',
].includes(proxy.type)
) {
delete proxy.tls;
}

View File

@@ -149,9 +149,13 @@ export default function ClashMeta_Producer() {
}
}
if (
['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(
proxy.type,
)
[
'trojan',
'tuic',
'hysteria',
'hysteria2',
'juicity',
].includes(proxy.type)
) {
delete proxy.tls;
}

View File

@@ -152,9 +152,13 @@ export default function ShadowRocket_Producer() {
}
}
if (
['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(
proxy.type,
)
[
'trojan',
'tuic',
'hysteria',
'hysteria2',
'juicity',
].includes(proxy.type)
) {
delete proxy.tls;
}

View File

@@ -202,8 +202,8 @@ const tlsParser = (proxy, parsedProxy) => {
parsedProxy.tls.alpn = [proxy.alpn];
} else if (Array.isArray(proxy.alpn)) parsedProxy.tls.alpn = proxy.alpn;
if (proxy.ca) parsedProxy.tls.certificate_path = `${proxy.ca}`;
if (proxy.ca_str) parsedProxy.tls.certificate = proxy.ca_sStr;
if (proxy['ca-str']) parsedProxy.tls.certificate = proxy['ca-str'];
if (proxy.ca_str) parsedProxy.tls.certificate = [proxy.ca_str];
if (proxy['ca-str']) parsedProxy.tls.certificate = [proxy['ca-str']];
if (proxy['client-fingerprint'] && proxy['client-fingerprint'] !== '')
parsedProxy.tls.utls = {
enabled: true,

View File

@@ -21,6 +21,8 @@ export default function Stash_Producer() {
'wireguard',
'hysteria',
'hysteria2',
'ssh',
'juicity',
].includes(proxy.type) ||
(proxy.type === 'ss' &&
![
@@ -232,9 +234,13 @@ export default function Stash_Producer() {
}
}
if (
['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(
proxy.type,
)
[
'trojan',
'tuic',
'hysteria',
'hysteria2',
'juicity',
].includes(proxy.type)
) {
delete proxy.tls;
}

View File

@@ -16,7 +16,11 @@ export default function URI_Producer() {
delete proxy[key];
}
}
if (['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(proxy.type)) {
if (
['trojan', 'tuic', 'hysteria', 'hysteria2', 'juicity'].includes(
proxy.type,
)
) {
delete proxy.tls;
}
if (proxy.server && isIPv6(proxy.server)) {

View File

@@ -123,10 +123,11 @@ async function downloadSubscription(req, res) {
['localFirst', 'remoteFirst'].includes(sub.mergeSources)
) {
try {
url = `${url || sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0];
url =
`${url || sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0] || '';
let $arguments = {};
const rawArgs = url.split('#');
@@ -283,10 +284,11 @@ async function downloadCollection(req, res) {
['localFirst', 'remoteFirst'].includes(sub.mergeSources)
) {
try {
let url = `${sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0];
let url =
`${sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0] || '';
let $arguments = {};
const rawArgs = url.split('#');

View File

@@ -34,6 +34,11 @@ export default function register($app) {
async function getFlowInfo(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
let { url } = req.query;
if (url) {
url = decodeURIComponent(url);
$.info(`指定远程订阅 URL: ${url}`);
}
const allSubs = $.read(SUBS_KEY);
const sub = findByName(allSubs, name);
if (!sub) {
@@ -68,10 +73,11 @@ async function getFlowInfo(req, res) {
return;
}
try {
let url = `${sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0];
url =
`${url || sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0] || '';
let $arguments = {};
const rawArgs = url.split('#');

View File

@@ -15,7 +15,7 @@ import $ from '@/core/app';
const tasks = new Map();
export default async function download(
rawUrl,
rawUrl = '',
ua,
timeout,
proxy,

View File

@@ -11,7 +11,7 @@ export function getFlowField(headers) {
return headers[subkey];
}
export async function getFlowHeaders(rawUrl, ua, timeout, proxy, flowUrl) {
let url = flowUrl || rawUrl;
let url = flowUrl || rawUrl || '';
let $arguments = {};
const rawArgs = url.split('#');
url = url.split('#')[0];

11
backend/src/utils/rs.js Normal file
View File

@@ -0,0 +1,11 @@
import rs from 'jsrsasign';
export function generateFingerprint(caStr) {
const hex = rs.pemtohex(caStr);
const fingerPrint = rs.KJUR.crypto.Util.hashHex(hex, 'sha256');
return fingerPrint.match(/.{2}/g).join(':').toUpperCase();
}
export default {
generateFingerprint,
};

View File

@@ -103,7 +103,7 @@ function operator(proxies = [], targetPlatform, context) {
// 4. 一个比较折腾的方案: 在脚本操作中, 把内容同步到另一个 gist
// 见 https://t.me/zhetengsha/1428
//
// const content = ProxyUtils.produce(proxies, platform)
// const content = ProxyUtils.produce([...proxies], platform)
// // YAML
// ProxyUtils.yaml.load('YAML String')