mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 15:09:03 +08:00
feat: 哪吒探针网络监控接口提示不兼容的节点, 支持传入节点名
This commit is contained in:
parent
370d228b04
commit
4819ae95e4
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.289",
|
"version": "2.14.290",
|
||||||
"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": {
|
||||||
|
@ -31,7 +31,7 @@ export default function register($app) {
|
|||||||
await downloadSubscription(req, res);
|
await downloadSubscription(req, res);
|
||||||
});
|
});
|
||||||
$app.get(
|
$app.get(
|
||||||
'/download/collection/:name/api/v1/monitor/:index',
|
'/download/collection/:name/api/v1/monitor/:nezhaIndex',
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
req.query.platform = 'JSON';
|
req.query.platform = 'JSON';
|
||||||
req.query.produceType = 'internal';
|
req.query.produceType = 'internal';
|
||||||
@ -39,7 +39,7 @@ export default function register($app) {
|
|||||||
await downloadCollection(req, res);
|
await downloadCollection(req, res);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
$app.get('/download/:name/api/v1/monitor/:index', async (req, res) => {
|
$app.get('/download/:name/api/v1/monitor/:nezhaIndex', async (req, res) => {
|
||||||
req.query.platform = 'JSON';
|
req.query.platform = 'JSON';
|
||||||
req.query.produceType = 'internal';
|
req.query.produceType = 'internal';
|
||||||
req.query.resultFormat = 'nezha-monitor';
|
req.query.resultFormat = 'nezha-monitor';
|
||||||
@ -48,9 +48,9 @@ export default function register($app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function downloadSubscription(req, res) {
|
async function downloadSubscription(req, res) {
|
||||||
let { name, index: nezhaIndex } = req.params;
|
let { name, nezhaIndex } = req.params;
|
||||||
nezhaIndex = parseInt(nezhaIndex, 10);
|
|
||||||
name = decodeURIComponent(name);
|
name = decodeURIComponent(name);
|
||||||
|
nezhaIndex = decodeURIComponent(nezhaIndex);
|
||||||
|
|
||||||
const platform =
|
const platform =
|
||||||
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
||||||
@ -173,6 +173,9 @@ async function downloadSubscription(req, res) {
|
|||||||
if (resultFormat === 'nezha') {
|
if (resultFormat === 'nezha') {
|
||||||
output = nezhaTransform(output);
|
output = nezhaTransform(output);
|
||||||
} else if (resultFormat === 'nezha-monitor') {
|
} else if (resultFormat === 'nezha-monitor') {
|
||||||
|
nezhaIndex = /^\d+$/.test(nezhaIndex)
|
||||||
|
? parseInt(nezhaIndex, 10)
|
||||||
|
: output.findIndex((i) => i.name === nezhaIndex);
|
||||||
output = await nezhaMonitor(output[nezhaIndex], nezhaIndex);
|
output = await nezhaMonitor(output[nezhaIndex], nezhaIndex);
|
||||||
}
|
}
|
||||||
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
||||||
@ -211,9 +214,9 @@ async function downloadSubscription(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function downloadCollection(req, res) {
|
async function downloadCollection(req, res) {
|
||||||
let { name, index: nezhaIndex } = req.params;
|
let { name, nezhaIndex } = req.params;
|
||||||
nezhaIndex = parseInt(nezhaIndex, 10);
|
|
||||||
name = decodeURIComponent(name);
|
name = decodeURIComponent(name);
|
||||||
|
nezhaIndex = decodeURIComponent(nezhaIndex);
|
||||||
|
|
||||||
const platform =
|
const platform =
|
||||||
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
||||||
@ -321,6 +324,9 @@ async function downloadCollection(req, res) {
|
|||||||
if (resultFormat === 'nezha') {
|
if (resultFormat === 'nezha') {
|
||||||
output = nezhaTransform(output);
|
output = nezhaTransform(output);
|
||||||
} else if (resultFormat === 'nezha-monitor') {
|
} else if (resultFormat === 'nezha-monitor') {
|
||||||
|
nezhaIndex = /^\d+$/.test(nezhaIndex)
|
||||||
|
? parseInt(nezhaIndex, 10)
|
||||||
|
: output.findIndex((i) => i.name === nezhaIndex);
|
||||||
output = await nezhaMonitor(output[nezhaIndex], nezhaIndex);
|
output = await nezhaMonitor(output[nezhaIndex], nezhaIndex);
|
||||||
}
|
}
|
||||||
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
||||||
@ -372,6 +378,7 @@ async function nezhaMonitor(proxy, index) {
|
|||||||
if (!isLoon && !isSurge)
|
if (!isLoon && !isSurge)
|
||||||
throw new Error('仅支持 Loon 和 Surge(ability=http-client-policy)');
|
throw new Error('仅支持 Loon 和 Surge(ability=http-client-policy)');
|
||||||
const node = ProxyUtils.produce([proxy], isLoon ? 'Loon' : 'Surge');
|
const node = ProxyUtils.produce([proxy], isLoon ? 'Loon' : 'Surge');
|
||||||
|
if (!node) throw new Error('当前客户端不兼容此节点');
|
||||||
const monitors = proxy._monitors || [
|
const monitors = proxy._monitors || [
|
||||||
{
|
{
|
||||||
name: 'Cloudflare',
|
name: 'Cloudflare',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user