Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

684 B
Raw Blame
import { DnsCacheManager } from "dns-caching";

import { createLogger } from "@homarr/core/infrastructure/logs";

import { dnsEnv } from "./env";

// Add global type augmentation for homarr
declare global {
  var homarr: {
    dnsCacheManager?: DnsCacheManager;
    // add other properties if needed
  };
}

const logger = createLogger({ module: "dns" });

if (dnsEnv.ENABLE_DNS_CACHING) {
  // 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();
}