fix: add dns caching (#3736)

This commit is contained in:
Meier Lukas
2025-09-03 17:37:18 +02:00
committed by GitHub
parent ca488f8210
commit fb6b5e88ff
7 changed files with 50 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
import { DnsCacheManager } from "dns-caching";
import { logger } from "@homarr/log";
// Add global type augmentation for homarr
declare global {
var homarr: {
dnsCacheManager?: DnsCacheManager;
// add other properties if needed
};
}
// Initialize global.homarr if not present
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
global.homarr ??= {};
global.homarr.dnsCacheManager ??= new DnsCacheManager({
cacheMaxEntries: 1000,
forceMinTtl: 5 * 60 * 1000, // 5 minutes
logger,
});
global.homarr.dnsCacheManager.initialize();

View File

@@ -3,6 +3,9 @@ import { Agent } from "undici";
import { logger } from "@homarr/log";
// The below import statement initializes dns-caching
import "./dns";
export class LoggingAgent extends Agent {
constructor(...props: ConstructorParameters<typeof Agent>) {
super(...props);