mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 07:28:59 +08:00
feat: 哪吒探针网络监控接口支持用参数传入检测次数; 节点字段上自定义的多个次数, 只取最大值
This commit is contained in:
parent
4819ae95e4
commit
c7329c32eb
@ -176,7 +176,11 @@ async function downloadSubscription(req, res) {
|
|||||||
nezhaIndex = /^\d+$/.test(nezhaIndex)
|
nezhaIndex = /^\d+$/.test(nezhaIndex)
|
||||||
? parseInt(nezhaIndex, 10)
|
? parseInt(nezhaIndex, 10)
|
||||||
: output.findIndex((i) => i.name === nezhaIndex);
|
: output.findIndex((i) => i.name === nezhaIndex);
|
||||||
output = await nezhaMonitor(output[nezhaIndex], nezhaIndex);
|
output = await nezhaMonitor(
|
||||||
|
output[nezhaIndex],
|
||||||
|
nezhaIndex,
|
||||||
|
req.query,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
||||||
output,
|
output,
|
||||||
@ -327,7 +331,11 @@ async function downloadCollection(req, res) {
|
|||||||
nezhaIndex = /^\d+$/.test(nezhaIndex)
|
nezhaIndex = /^\d+$/.test(nezhaIndex)
|
||||||
? parseInt(nezhaIndex, 10)
|
? parseInt(nezhaIndex, 10)
|
||||||
: output.findIndex((i) => i.name === nezhaIndex);
|
: output.findIndex((i) => i.name === nezhaIndex);
|
||||||
output = await nezhaMonitor(output[nezhaIndex], nezhaIndex);
|
output = await nezhaMonitor(
|
||||||
|
output[nezhaIndex],
|
||||||
|
nezhaIndex,
|
||||||
|
req.query,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
res.set('Content-Type', 'application/json;charset=utf-8').send(
|
||||||
output,
|
output,
|
||||||
@ -366,7 +374,7 @@ async function downloadCollection(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function nezhaMonitor(proxy, index) {
|
async function nezhaMonitor(proxy, index, query) {
|
||||||
const result = {
|
const result = {
|
||||||
code: 0,
|
code: 0,
|
||||||
message: 'success',
|
message: 'success',
|
||||||
@ -395,7 +403,8 @@ async function nezhaMonitor(proxy, index) {
|
|||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
const number =
|
||||||
|
query.number || Math.max(...monitors.map((i) => i.number)) || 3;
|
||||||
for (const monitor of monitors) {
|
for (const monitor of monitors) {
|
||||||
const interval = 10 * 60 * 1000;
|
const interval = 10 * 60 * 1000;
|
||||||
const data = {
|
const data = {
|
||||||
@ -406,8 +415,7 @@ async function nezhaMonitor(proxy, index) {
|
|||||||
created_at: [],
|
created_at: [],
|
||||||
avg_delay: [],
|
avg_delay: [],
|
||||||
};
|
};
|
||||||
|
for (let index = 0; index < number; index++) {
|
||||||
for (let index = 0; index < monitor.number; index++) {
|
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
try {
|
try {
|
||||||
await $.http[(monitor.method || 'HEAD').toLowerCase()]({
|
await $.http[(monitor.method || 'HEAD').toLowerCase()]({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user