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.

refactor(dns): move to core package (#4687)

Meier Lukasf4bb90013a79
diff --git a/packages/common/env.ts b/packages/common/env.ts
index c52abbd25..cbccc8b70 100644
--- a/packages/common/env.ts
+++ b/packages/common/env.ts
@@ -24,12 +24,10 @@ export const env = createEnv({
message: `SECRET_ENCRYPTION_KEY must only contain hex characters${errorSuffix}`,
}),
NO_EXTERNAL_CONNECTION: createBooleanSchema(false),
- ENABLE_DNS_CACHING: createBooleanSchema(false),
},
runtimeEnv: {
SECRET_ENCRYPTION_KEY: process.env.SECRET_ENCRYPTION_KEY,
NODE_ENV: process.env.NODE_ENV,
NO_EXTERNAL_CONNECTION: process.env.NO_EXTERNAL_CONNECTION,
- ENABLE_DNS_CACHING: process.env.ENABLE_DNS_CACHING,
},
});
diff --git a/packages/common/package.json b/packages/common/package.json
index e8f085369..fa5decbcc 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -8,7 +8,6 @@
".": "./index.ts",
"./types": "./src/types.ts",
"./server": "./src/server.ts",
- "./init-dns": "./src/dns.ts",
"./client": "./src/client.ts",
"./env": "./env.ts"
},
@@ -30,7 +29,6 @@
"@homarr/core": "workspace:^0.1.0",
"@paralleldrive/cuid2": "^3.1.0",
"dayjs": "^1.11.19",
- "dns-caching": "^0.2.9",
"next": "16.0.10",
"octokit": "^5.0.5",
"react": "19.2.3",
diff --git a/packages/common/src/fetch-agent.ts b/packages/common/src/fetch-agent.ts
index 05afc1abc..d256bd9df 100644
--- a/packages/common/src/fetch-agent.ts
+++ b/packages/common/src/fetch-agent.ts
@@ -4,7 +4,7 @@ import { Agent } from "undici";
import { createLogger } from "@homarr/core/infrastructure/logs";
// The below import statement initializes dns-caching
-import "./dns";
+import "@homarr/core/infrastructure/dns/init";
const logger = createLogger({ module: "fetchAgent" });
diff --git a/packages/core/package.json b/packages/core/package.json
index 7f5086c87..1a61fa398 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -17,7 +17,8 @@
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
- "./infrastructure/certificates/hostnames/db/postgresql": "./src/infrastructure/certificates/hostnames/db/postgresql.ts"
+ "./infrastructure/certificates/hostnames/db/postgresql": "./src/infrastructure/certificates/hostnames/db/postgresql.ts",
+ "./infrastructure/dns/init": "./src/infrastructure/dns/init.ts"
},
"typesVersions": {
"*": {
@@ -36,6 +37,7 @@
"dependencies": {
"@t3-oss/env-nextjs": "^0.13.8",
"better-sqlite3": "^12.5.0",
+ "dns-caching": "^0.2.9",
"drizzle-orm": "^0.45.1",
"ioredis": "5.8.2",
"mysql2": "3.15.3",
diff --git a/packages/core/src/infrastructure/dns/env.ts b/packages/core/src/infrastructure/dns/env.ts
new file mode 100644
index 000000000..96dd526b8
--- /dev/null
+++ b/packages/core/src/infrastructure/dns/env.ts
@@ -0,0 +1,8 @@
+import { createBooleanSchema, createEnv } from "../env";
+
+export const dnsEnv = createEnv({
+ server: {
+ ENABLE_DNS_CACHING: createBooleanSchema(false),
+ },
+ experimental__runtimeEnv: process.env,
+});
diff --git a/packages/common/src/dns.ts b/packages/core/src/infrastructure/dns/init.ts
similarity index 90%
rename from packages/common/src/dns.ts
rename to packages/core/src/infrastructure/dns/init.ts
index 80fde6e1a..fa9301576 100644
--- a/packages/common/src/dns.ts
+++ b/packages/core/src/infrastructure/dns/init.ts
@@ -2,7 +2,7 @@ import { DnsCacheManager } from "dns-caching";
import { createLogger } from "@homarr/core/infrastructure/logs";
-import { env } from "../env";
+import { dnsEnv } from "./env";
// Add global type augmentation for homarr
declare global {
@@ -23,6 +23,6 @@ global.homarr.dnsCacheManager ??= new DnsCacheManager({
logger,
});
-if (env.ENABLE_DNS_CACHING) {
+if (dnsEnv.ENABLE_DNS_CACHING) {
global.homarr.dnsCacheManager.initialize();
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 783bf4860..edf0096d0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -877,9 +877,6 @@ importers:
dayjs:
specifier: ^1.11.19
version: 1.11.19
- dns-caching:
- specifier: ^0.2.9
- version: 0.2.9
next:
specifier: 16.0.10
@@ -926,6 +923,9 @@ importers:
better-sqlite3:
specifier: ^12.5.0
version: 12.5.0
+ dns-caching:
+ specifier: ^0.2.9
+ version: 0.2.9
drizzle-orm:
specifier: ^0.45.1