mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bebcff1d3 | ||
|
|
7b8f6f7e52 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.32",
|
"version": "2.14.34",
|
||||||
"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;
|
||||||
@@ -206,6 +205,17 @@ function lastParse(proxy) {
|
|||||||
proxy.sni = proxy.server;
|
proxy.sni = proxy.server;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 非 tls, 有 ws/http 传输层, 使用域名的节点, 将设置传输层 Host 防止之后域名解析后丢失域名
|
||||||
|
if (
|
||||||
|
!proxy.tls &&
|
||||||
|
['ws', 'http'].includes(proxy.network) &&
|
||||||
|
!isIP(proxy.server)
|
||||||
|
) {
|
||||||
|
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
||||||
|
proxy[`${proxy.network}-opts`].headers =
|
||||||
|
proxy[`${proxy.network}-opts`].headers || {};
|
||||||
|
proxy[`${proxy.network}-opts`].headers.Host = proxy.server;
|
||||||
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user