mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 11:28:59 +08:00
feat: 域名解析新增 Tencent, Ali; 脚本下载失败, 脚本操作失败, 脚本过滤失败时都会报错了
This commit is contained in:
parent
49c7107d20
commit
7b8f6f7e52
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.32",
|
"version": "2.14.33",
|
||||||
"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": {
|
||||||
|
@ -90,8 +90,7 @@ async function process(proxies, operators = [], targetPlatform) {
|
|||||||
$.error(
|
$.error(
|
||||||
`Error when downloading remote script: ${item.args.content}.\n Reason: ${err}`,
|
`Error when downloading remote script: ${item.args.content}.\n Reason: ${err}`,
|
||||||
);
|
);
|
||||||
// skip the script if download failed.
|
throw new Error(`无法下载脚本: ${url}`);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
script = content;
|
script = content;
|
||||||
|
@ -378,6 +378,47 @@ const DOMAIN_RESOLVERS = {
|
|||||||
resourceCache.set(id, result);
|
resourceCache.set(id, result);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
Ali: async function (domain) {
|
||||||
|
const id = hex_md5(`ALI:${domain}`);
|
||||||
|
const cached = resourceCache.get(id);
|
||||||
|
if (cached) return cached;
|
||||||
|
const resp = await $.http.get({
|
||||||
|
url: `http://223.6.6.6/resolve?name=${encodeURIComponent(
|
||||||
|
domain,
|
||||||
|
)}&type=A&short=1`,
|
||||||
|
headers: {
|
||||||
|
accept: 'application/dns-json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const answers = JSON.parse(resp.body);
|
||||||
|
if (answers.length === 0) {
|
||||||
|
throw new Error('No answers');
|
||||||
|
}
|
||||||
|
const result = answers[answers.length - 1];
|
||||||
|
resourceCache.set(id, result);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
Tencent: async function (domain) {
|
||||||
|
const id = hex_md5(`ALI:${domain}`);
|
||||||
|
const cached = resourceCache.get(id);
|
||||||
|
if (cached) return cached;
|
||||||
|
const resp = await $.http.get({
|
||||||
|
url: `http://119.28.28.28/d?type=A&dn=${encodeURIComponent(
|
||||||
|
domain,
|
||||||
|
)}`,
|
||||||
|
headers: {
|
||||||
|
accept: 'application/dns-json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const answers = resp.body.split(';').map((i) => i.split(',')[0]);
|
||||||
|
console.log(`answers`, answers);
|
||||||
|
if (answers.length === 0) {
|
||||||
|
throw new Error('No answers');
|
||||||
|
}
|
||||||
|
const result = answers[answers.length - 1];
|
||||||
|
resourceCache.set(id, result);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function ResolveDomainOperator({ provider }) {
|
function ResolveDomainOperator({ provider }) {
|
||||||
@ -566,7 +607,8 @@ async function ApplyFilter(filter, objs) {
|
|||||||
selected = await filter.func(objs);
|
selected = await filter.func(objs);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// print log and skip this filter
|
// print log and skip this filter
|
||||||
$.log(`Cannot apply filter ${filter.name}\n Reason: ${err}`);
|
$.error(`Cannot apply filter ${filter.name}\n Reason: ${err}`);
|
||||||
|
throw new Error(`脚本过滤失败 ${err.message ?? err}`);
|
||||||
}
|
}
|
||||||
return objs.filter((_, i) => selected[i]);
|
return objs.filter((_, i) => selected[i]);
|
||||||
}
|
}
|
||||||
@ -578,7 +620,8 @@ async function ApplyOperator(operator, objs) {
|
|||||||
if (output_) output = output_;
|
if (output_) output = output_;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// print log and skip this operator
|
// print log and skip this operator
|
||||||
$.log(`Cannot apply operator ${operator.name}! Reason: ${err}`);
|
$.error(`Cannot apply operator ${operator.name}! Reason: ${err}`);
|
||||||
|
throw new Error(`脚本操作失败 ${err.message ?? err}`);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user