mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
feat: remove hot ip in debug info
This commit is contained in:
@@ -48,7 +48,6 @@ app.context.debug = {
|
|||||||
etag: 0,
|
etag: 0,
|
||||||
paths: [],
|
paths: [],
|
||||||
routes: [],
|
routes: [],
|
||||||
ips: [],
|
|
||||||
errorPaths: [],
|
errorPaths: [],
|
||||||
errorRoutes: [],
|
errorRoutes: [],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ module.exports = async (ctx, next) => {
|
|||||||
}
|
}
|
||||||
ctx.debug.paths[ctx.request.path]++;
|
ctx.debug.paths[ctx.request.path]++;
|
||||||
|
|
||||||
const ip = ctx.ips[0] || ctx.ip;
|
|
||||||
if (!ctx.debug.ips[ip]) {
|
|
||||||
ctx.debug.ips[ip] = 0;
|
|
||||||
}
|
|
||||||
ctx.debug.ips[ip]++;
|
|
||||||
ctx.debug.request++;
|
ctx.debug.request++;
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
|
|||||||
@@ -48,13 +48,6 @@ module.exports = async (ctx) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const ips = Object.keys(ctx.debug.ips).sort((a, b) => ctx.debug.ips[b] - ctx.debug.ips[a]);
|
|
||||||
const hotIPs = ips.slice(0, 50);
|
|
||||||
let hotIPsValue = '';
|
|
||||||
hotIPs.forEach((item) => {
|
|
||||||
hotIPsValue += `${ctx.debug.ips[item]} ${item}<br>`;
|
|
||||||
});
|
|
||||||
|
|
||||||
let showDebug;
|
let showDebug;
|
||||||
if (!config.debugInfo || config.debugInfo === 'false') {
|
if (!config.debugInfo || config.debugInfo === 'false') {
|
||||||
showDebug = false;
|
showDebug = false;
|
||||||
@@ -115,10 +108,6 @@ module.exports = async (ctx) => {
|
|||||||
name: 'Hot Paths',
|
name: 'Hot Paths',
|
||||||
value: hotPathsValue,
|
value: hotPathsValue,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Hot IP',
|
|
||||||
value: hotIPsValue,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Hot Error Routes',
|
name: 'Hot Error Routes',
|
||||||
value: hotErrorRoutesValue,
|
value: hotErrorRoutesValue,
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ describe('debug', () => {
|
|||||||
case 'Hot Paths:':
|
case 'Hot Paths:':
|
||||||
expect(value).toBe('3 /test/1<br>2 /test/2<br>2 /test/empty<br>1 /<br>');
|
expect(value).toBe('3 /test/1<br>2 /test/2<br>2 /test/empty<br>1 /<br>');
|
||||||
break;
|
break;
|
||||||
case 'Hot IP:':
|
|
||||||
expect(value).toBe('5 233.233.233.233<br>3 233.233.233.234<br>');
|
|
||||||
break;
|
|
||||||
case 'Hot Error Routes:':
|
case 'Hot Error Routes:':
|
||||||
expect(value).toBe('1 /test/:id<br>');
|
expect(value).toBe('1 /test/:id<br>');
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user