mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 13:49:02 +08:00
fix: 处理预览时子订阅出错的情况
This commit is contained in:
parent
69726cd5c4
commit
d636e1b94c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.115",
|
"version": "2.14.116",
|
||||||
"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": {
|
||||||
|
@ -84,7 +84,8 @@ export default function ShadowRocket_Producer() {
|
|||||||
} else if (proxy.type === 'hysteria2') {
|
} else if (proxy.type === 'hysteria2') {
|
||||||
if (
|
if (
|
||||||
proxy['obfs-password'] &&
|
proxy['obfs-password'] &&
|
||||||
proxy.obfs == 'salamander') {
|
proxy.obfs == 'salamander'
|
||||||
|
) {
|
||||||
proxy.obfs = proxy['obfs-password'];
|
proxy.obfs = proxy['obfs-password'];
|
||||||
delete proxy['obfs-password'];
|
delete proxy['obfs-password'];
|
||||||
}
|
}
|
||||||
|
@ -87,64 +87,69 @@ async function compareCollection(req, res) {
|
|||||||
const collection = req.body;
|
const collection = req.body;
|
||||||
const subnames = collection.subscriptions;
|
const subnames = collection.subscriptions;
|
||||||
const results = {};
|
const results = {};
|
||||||
|
let hasError;
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
subnames.map(async (name) => {
|
subnames.map(async (name) => {
|
||||||
const sub = findByName(allSubs, name);
|
if (!hasError) {
|
||||||
try {
|
const sub = findByName(allSubs, name);
|
||||||
let raw;
|
try {
|
||||||
if (
|
let raw;
|
||||||
sub.source === 'local' &&
|
if (
|
||||||
!['localFirst', 'remoteFirst'].includes(
|
sub.source === 'local' &&
|
||||||
sub.mergeSources,
|
!['localFirst', 'remoteFirst'].includes(
|
||||||
)
|
sub.mergeSources,
|
||||||
) {
|
)
|
||||||
raw = sub.content;
|
) {
|
||||||
} else {
|
raw = sub.content;
|
||||||
raw = await Promise.all(
|
} else {
|
||||||
sub.url
|
raw = await Promise.all(
|
||||||
.split(/[\r\n]+/)
|
sub.url
|
||||||
.map((i) => i.trim())
|
.split(/[\r\n]+/)
|
||||||
.filter((i) => i.length)
|
.map((i) => i.trim())
|
||||||
.map((url) => download(url, sub.ua)),
|
.filter((i) => i.length)
|
||||||
|
.map((url) => download(url, sub.ua)),
|
||||||
|
);
|
||||||
|
if (sub.mergeSources === 'localFirst') {
|
||||||
|
raw.unshift(sub.content);
|
||||||
|
} else if (sub.mergeSources === 'remoteFirst') {
|
||||||
|
raw.push(sub.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// parse proxies
|
||||||
|
let currentProxies = (Array.isArray(raw) ? raw : [raw])
|
||||||
|
.map((i) => ProxyUtils.parse(i))
|
||||||
|
.flat();
|
||||||
|
|
||||||
|
currentProxies.forEach((proxy) => {
|
||||||
|
proxy.subName = sub.name;
|
||||||
|
proxy.collectionName = collection.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
// apply processors
|
||||||
|
currentProxies = await ProxyUtils.process(
|
||||||
|
currentProxies,
|
||||||
|
sub.process || [],
|
||||||
|
'JSON',
|
||||||
|
{ [sub.name]: sub, _collection: collection },
|
||||||
);
|
);
|
||||||
if (sub.mergeSources === 'localFirst') {
|
results[name] = currentProxies;
|
||||||
raw.unshift(sub.content);
|
} catch (err) {
|
||||||
} else if (sub.mergeSources === 'remoteFirst') {
|
if (!hasError) {
|
||||||
raw.push(sub.content);
|
hasError = true;
|
||||||
|
failed(
|
||||||
|
res,
|
||||||
|
new InternalServerError(
|
||||||
|
'PROCESS_FAILED',
|
||||||
|
`处理子订阅 ${name} 失败`,
|
||||||
|
`Reason: ${err}`,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// parse proxies
|
|
||||||
let currentProxies = (Array.isArray(raw) ? raw : [raw])
|
|
||||||
.map((i) => ProxyUtils.parse(i))
|
|
||||||
.flat();
|
|
||||||
|
|
||||||
currentProxies.forEach((proxy) => {
|
|
||||||
proxy.subName = sub.name;
|
|
||||||
proxy.collectionName = collection.name;
|
|
||||||
});
|
|
||||||
|
|
||||||
// apply processors
|
|
||||||
currentProxies = await ProxyUtils.process(
|
|
||||||
currentProxies,
|
|
||||||
sub.process || [],
|
|
||||||
'JSON',
|
|
||||||
{ [sub.name]: sub, _collection: collection },
|
|
||||||
);
|
|
||||||
results[name] = currentProxies;
|
|
||||||
} catch (err) {
|
|
||||||
failed(
|
|
||||||
res,
|
|
||||||
new InternalServerError(
|
|
||||||
'PROCESS_FAILED',
|
|
||||||
`处理子订阅 ${name} 失败`,
|
|
||||||
`Reason: ${err}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
if (hasError) return;
|
||||||
// merge proxies with the original order
|
// merge proxies with the original order
|
||||||
const original = Array.prototype.concat.apply(
|
const original = Array.prototype.concat.apply(
|
||||||
[],
|
[],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user