Compare commits

...

2 Commits

Author SHA1 Message Date
xream
e4f646af0c feat: 若设置 $options._res.headers, 拉取文件时将设置自定义响应头
Some checks failed
build / build (push) Has been cancelled
2025-05-28 13:46:57 +08:00
xream
532be2ff8c Stash 正式版支持 VLESS REALITY(xtls-rprx-vision)
Some checks failed
build / build (push) Has been cancelled
2025-05-27 19:46:31 +08:00
6 changed files with 61 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.19.54",
"version": "2.19.56",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {

View File

@@ -44,11 +44,9 @@ export default function Stash_Producer() {
'2022-blake3-aes-256-gcm',
].includes(proxy.cipher)) ||
(proxy.type === 'snell' && String(proxy.version) === '4') ||
(opts['include-unsupported-proxy']
? proxy.type === 'vless' &&
proxy['reality-opts'] &&
!['xtls-rprx-vision'].includes(proxy.flow)
: proxy.type === 'vless' && proxy['reality-opts'])
(proxy.type === 'vless' &&
proxy['reality-opts'] &&
!['xtls-rprx-vision'].includes(proxy.flow))
) {
return false;
} else if (proxy['underlying-proxy'] || proxy['dialer-proxy']) {

View File

@@ -150,6 +150,7 @@ async function getFile(req, res) {
proxy,
noCache,
produceType,
all: true,
});
try {
@@ -184,9 +185,15 @@ async function getFile(req, res) {
)}`,
);
}
res.set('Content-Type', 'text/plain; charset=utf-8').send(
output ?? '',
);
res.set('Content-Type', 'text/plain; charset=utf-8');
if (output?.$options?._res?.headers) {
Object.entries(output.$options._res.headers).forEach(
([key, value]) => {
res.set(key, value);
},
);
}
res.send(output?.$content ?? '');
} catch (err) {
$.notify(
`🌍 Sub-Store 下载文件失败`,

View File

@@ -40,6 +40,7 @@ async function produceArtifact({
$options,
proxy,
noCache,
all,
}) {
platform = platform || 'JSON';
@@ -595,7 +596,7 @@ async function produceArtifact({
)
: { $content: filesContent, $files: files, $options };
return processed?.$content ?? '';
return (all ? processed : processed?.$content) ?? '';
}
}

View File

@@ -61,41 +61,41 @@ export function getPlatformFromHeaders(headers) {
return getPlatformFromUserAgent({ ua, UA, accept });
}
export function shouldIncludeUnsupportedProxy(platform, ua) {
try {
const target = getPlatformFromUserAgent({
UA: ua,
ua: ua.toLowerCase(),
});
if (!['Stash', 'Egern', 'Loon'].includes(target)) {
return false;
}
const coerceVersion = coerce(ua);
$.log(JSON.stringify(coerceVersion, null, 2));
const { version } = coerceVersion;
if (
platform === 'Stash' &&
target === 'Stash' &&
gte(version, '3.1.0')
) {
return true;
}
if (
platform === 'Egern' &&
target === 'Egern' &&
gte(version, '1.29.0')
) {
return true;
}
// Loon 的 UA 不规范, version 取出来是 build
if (
platform === 'Loon' &&
target === 'Loon' &&
gte(version, '842.0.0')
) {
return true;
}
} catch (e) {
$.error(`获取版本号失败: ${e}`);
}
// try {
// const target = getPlatformFromUserAgent({
// UA: ua,
// ua: ua.toLowerCase(),
// });
// if (!['Stash', 'Egern', 'Loon'].includes(target)) {
// return false;
// }
// const coerceVersion = coerce(ua);
// $.log(JSON.stringify(coerceVersion, null, 2));
// const { version } = coerceVersion;
// if (
// platform === 'Stash' &&
// target === 'Stash' &&
// gte(version, '3.1.0')
// ) {
// return true;
// }
// if (
// platform === 'Egern' &&
// target === 'Egern' &&
// gte(version, '1.29.0')
// ) {
// return true;
// }
// // Loon 的 UA 不规范, version 取出来是 build
// if (
// platform === 'Loon' &&
// target === 'Loon' &&
// gte(version, '842.0.0')
// ) {
// return true;
// }
// } catch (e) {
// $.error(`获取版本号失败: ${e}`);
// }
return false;
}

View File

@@ -59,6 +59,15 @@ function operator(proxies = [], targetPlatform, context) {
// }
// console.log($options)
// 若设置 $options._res.headers
// 则会在输出文件时设置响应头, 例如:
// $options._res = {
// headers: {
// 'X-Custom': '1'
// }
// }
// targetPlatform 为输出的目标平台
// lodash