Compare commits

...

3 Commits

Author SHA1 Message Date
xream
3e14f91347 feat: sing-box VLESS packet_encoding 2025-06-02 20:39:15 +08:00
xream
4aafdaaddb feat: 支持本地文件 2025-06-01 11:54:32 +08:00
xream
e4f646af0c feat: 若设置 $options._res.headers, 拉取文件时将设置自定义响应头
Some checks failed
build / build (push) Has been cancelled
2025-05-28 13:46:57 +08:00
6 changed files with 34 additions and 5 deletions

View File

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

View File

@@ -174,6 +174,17 @@ async function processFn(
);
throw new Error(`无法加载 ${type}: ${url}`);
}
} else if (url?.startsWith('/')) {
try {
const fs = eval(`require("fs")`);
script = fs.readFileSync(url, 'utf8');
// $.info(`Script loaded: >>>\n ${script}`);
} catch (err) {
$.error(
`Error when reading local script: ${item.args.content}.\n Reason: ${err}`,
);
throw new Error(`无法从该路径读取脚本文件: ${url}`);
}
} else {
// if this is a remote script, download it
try {

View File

@@ -519,6 +519,7 @@ const vlessParser = (proxy = {}) => {
};
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.xudp) parsedProxy.packet_encoding = 'xudp';
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
if (proxy.flow === 'xtls-rprx-vision') parsedProxy.flow = proxy.flow;
if (proxy.network === 'ws') wsParser(proxy, parsedProxy);

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

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