Compare commits

...

7 Commits

Author SHA1 Message Date
xream
9e0028219d feat: Shadowrocket 支持 anytls
Some checks failed
build / build (push) Has been cancelled
2025-05-26 17:24:39 +08:00
xream
54750d552b feat: 为 env 响应增加如何使用前端搭配后端的引导说明
Some checks failed
build / build (push) Has been cancelled
2025-05-25 00:58:06 +08:00
xream
0e7561a069 feat: Node.js 环境中 JSON 数据文件校验失败后会备份原文件, 创建新文件
Some checks failed
build / build (push) Has been cancelled
2025-05-24 18:40:30 +08:00
xream
6804c6368a fix: 修复 QX VLESS TLS
Some checks failed
build / build (push) Has been cancelled
2025-05-23 22:36:08 +08:00
xream
9c5d6e9a10 feat: 单条订阅和文件支持链接参数 produceType raw, 此时返回原始数据的数组
Some checks failed
build / build (push) Has been cancelled
2025-05-22 16:09:35 +08:00
xream
ef2d6be8eb feat: 预处理支持 Base64 兜底 2025-05-22 15:17:38 +08:00
xream
04e12a4836 fix: 修复 SOCKS5 URI
Some checks failed
build / build (push) Has been cancelled
2025-05-21 01:39:30 +08:00
9 changed files with 89 additions and 17 deletions

View File

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

View File

@@ -50,6 +50,26 @@ function Base64Encoded() {
return { name, test, parse };
}
function fallbackBase64Encoded() {
const name = 'Fallback Base64 Pre-processor';
const test = function (raw) {
return true;
};
const parse = function (raw) {
const decoded = Base64.decode(raw);
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
$.error(
`Fallback Base64 Pre-processor error: decoded line does not start with protocol`,
);
return raw;
}
return decoded;
};
return { name, test, parse };
}
function Clash() {
const name = 'Clash Pre-processor';
const test = function (raw) {
@@ -163,4 +183,11 @@ function FullConfig() {
return { name, test, parse };
}
export default [HTML(), Clash(), Base64Encoded(), SSD(), FullConfig()];
export default [
HTML(),
Clash(),
Base64Encoded(),
SSD(),
FullConfig(),
fallbackBase64Encoded(),
];

View File

@@ -405,6 +405,8 @@ function vless(proxy) {
else append(`,obfs=ws`);
} else if (proxy.network === 'http') {
append(`,obfs=http`);
} else if (['tcp'].includes(proxy.network)) {
if (proxy.tls) append(`,obfs=over-tls`);
} else if (!['tcp'].includes(proxy.network)) {
throw new Error(`network ${proxy.network} is unsupported`);
}

View File

@@ -9,7 +9,7 @@ export default function Shadowrocket_Producer() {
if (opts['include-unsupported-proxy']) return true;
if (proxy.type === 'snell' && String(proxy.version) === '4') {
return false;
} else if (['mieru', 'anytls'].includes(proxy.type)) {
} else if (['mieru'].includes(proxy.type)) {
return false;
}
return true;

View File

@@ -33,7 +33,9 @@ export default function URI_Producer() {
switch (proxy.type) {
case 'socks5':
result = `socks://${encodeURIComponent(
Base64.encode(`${proxy.username}:${proxy.password}`),
Base64.encode(
`${proxy.username ?? ''}:${proxy.password ?? ''}`,
),
)}@${proxy.server}:${proxy.port}#${proxy.name}`;
break;
case 'ss':

View File

@@ -77,7 +77,19 @@ function getEnv(req, res) {
if (req.query.share) {
env.feature.share = true;
}
success(res, env);
res.set('Content-Type', 'application/json;charset=UTF-8').send(
JSON.stringify(
{
status: 'success',
data: {
guide: '⚠️⚠️⚠️ 您当前看到的是后端的响应. 若想配合前端使用, 可访问官方前端 https://sub-store.vercel.app 后自行配置后端地址, 或一键配置后端 https://sub-store.vercel.app?api=https://a.com/xxx (假设 https://a.com 是你后端的域名, /xxx 是自定义路径). 需注意 HTTPS 前端无法请求非本地的 HTTP 后端(部分浏览器上也无法访问本地 HTTP 后端). 请配置反代或在局域网自建 HTTP 前端. 如果还有问题, 可查看此排查说明: https://t.me/zhetengsha/1068',
...env,
},
},
null,
2,
),
);
}
async function refresh(_, res) {

View File

@@ -174,7 +174,7 @@ async function produceArtifact({
}
}
if (produceType === 'raw') {
return (Array.isArray(raw) ? raw : [raw]).flat();
return JSON.stringify((Array.isArray(raw) ? raw : [raw]).flat());
}
// parse proxies
let proxies = (Array.isArray(raw) ? raw : [raw])
@@ -574,7 +574,7 @@ async function produceArtifact({
}
}
if (produceType === 'raw') {
return (Array.isArray(raw) ? raw : [raw]).flat();
return JSON.stringify((Array.isArray(raw) ? raw : [raw]).flat());
}
const files = (Array.isArray(raw) ? raw : [raw]).flat();
let filesContent = files

View File

@@ -10,6 +10,14 @@ const isEgern = 'object' == typeof egern;
const isLanceX = 'undefined' != typeof $native;
const isGUIforCores = typeof $Plugins !== 'undefined';
function isPlainObject(obj) {
return (
obj !== null &&
typeof obj === 'object' &&
[null, Object.prototype].includes(Object.getPrototypeOf(obj))
);
}
export class OpenAPI {
constructor(name = 'untitled', debug = false) {
this.name = name;
@@ -62,29 +70,50 @@ export class OpenAPI {
const basePath =
eval('process.env.SUB_STORE_DATA_BASE_PATH') || '.';
let rootPath = `${basePath}/root.json`;
const backupRootPath = `${basePath}/root_${Date.now()}.json`;
this.log(`Root path: ${rootPath}`);
if (!this.node.fs.existsSync(rootPath)) {
if (this.node.fs.existsSync(rootPath)) {
try {
this.root = JSON.parse(
this.node.fs.readFileSync(`${rootPath}`),
);
} catch (e) {
this.node.fs.copyFileSync(rootPath, backupRootPath);
this.error(
`Failed to parse ${rootPath}: ${e.message}. Backup created at ${backupRootPath}`,
);
}
}
if (!isPlainObject(this.root)) {
this.node.fs.writeFileSync(rootPath, JSON.stringify({}), {
flag: 'wx',
flag: 'w',
});
this.root = {};
} else {
this.root = JSON.parse(
this.node.fs.readFileSync(`${rootPath}`),
);
}
// create a json file with the given name if not exists
let fpath = `${basePath}/${this.name}.json`;
const backupPath = `${basePath}/${this.name}_${Date.now()}.json`;
this.log(`Data path: ${fpath}`);
if (!this.node.fs.existsSync(fpath)) {
if (this.node.fs.existsSync(fpath)) {
try {
this.cache = JSON.parse(
this.node.fs.readFileSync(`${fpath}`),
);
} catch (e) {
this.node.fs.copyFileSync(fpath, backupPath);
this.error(
`Failed to parse ${fpath}: ${e.message}. Backup created at ${backupPath}`,
);
}
}
if (!isPlainObject(this.cache)) {
this.node.fs.writeFileSync(fpath, JSON.stringify({}), {
flag: 'wx',
flag: 'w',
});
this.cache = {};
} else {
this.cache = JSON.parse(this.node.fs.readFileSync(`${fpath}`));
}
}
}

View File