feat(dns): implement dns caching
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
"lodash": "4.17.21",
|
||||
"lru-cache": "^11.0.2",
|
||||
"mime": "3",
|
||||
"next": "^14.2.25",
|
||||
"node-cache": "5.1.2",
|
||||
|
||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@@ -116,6 +116,9 @@ importers:
|
||||
lodash:
|
||||
specifier: 4.17.21
|
||||
version: 4.17.21
|
||||
lru-cache:
|
||||
specifier: ^11.0.2
|
||||
version: 11.0.2
|
||||
mime:
|
||||
specifier: '3'
|
||||
version: 3.0.0
|
||||
@@ -6744,6 +6747,10 @@ packages:
|
||||
resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==}
|
||||
engines: {node: 14 || >=16.14}
|
||||
|
||||
lru-cache@11.0.2:
|
||||
resolution: {integrity: sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
lru-cache@5.1.1:
|
||||
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
|
||||
|
||||
@@ -18036,6 +18043,8 @@ snapshots:
|
||||
|
||||
lru-cache@10.2.2: {}
|
||||
|
||||
lru-cache@11.0.2: {}
|
||||
|
||||
lru-cache@5.1.1:
|
||||
dependencies:
|
||||
yallist: 3.1.1
|
||||
|
||||
@@ -28,6 +28,7 @@ import discoverSettingRoutes from '@server/routes/settings/discover';
|
||||
import { ApiError } from '@server/types/error';
|
||||
import { appDataPath } from '@server/utils/appDataVolume';
|
||||
import { getAppVersion } from '@server/utils/appVersion';
|
||||
import { dnsCache } from '@server/utils/dnsCacheManager';
|
||||
import { getHostname } from '@server/utils/getHostname';
|
||||
import { Router } from 'express';
|
||||
import rateLimit from 'express-rate-limit';
|
||||
@@ -59,8 +60,23 @@ const filteredMainSettings = (
|
||||
return main;
|
||||
};
|
||||
|
||||
settingsRoutes.get('/dnsCache', async (req, res) => {
|
||||
const stats = dnsCache.getStats();
|
||||
const entries = dnsCache.getCacheEntries();
|
||||
|
||||
res.json({
|
||||
stats,
|
||||
entries,
|
||||
});
|
||||
});
|
||||
|
||||
settingsRoutes.get('/main', (req, res, next) => {
|
||||
const settings = getSettings();
|
||||
const stats = dnsCache.getStats();
|
||||
const entries = dnsCache.getCacheEntries();
|
||||
|
||||
console.log(entries);
|
||||
console.log(stats);
|
||||
|
||||
if (!req.user) {
|
||||
return next({ status: 400, message: 'User missing from request.' });
|
||||
|
||||
Reference in New Issue
Block a user