Add DNS module ported from Sloth Manager

Ports zone/record management across Cloudflare, Loopia, Pi-hole, Azure DNS,
cPanel, and Technitium onto the new stack. Unlike the original (one instance
per provider configured via env vars), providers are now configured through
the UI and support multiple named instances per type, with API
credentials encrypted at rest via the integration_credentials table.

- server/src/dns/adapters/*: each provider ported to a config-based factory
  (no more process.env reads), preserving each provider's original quirks
  (Pi-hole session auth, Azure record-set merging, Loopia XML-RPC, cPanel
  UAPI/API2 fallbacks, Technitium composite record IDs).
- server/src/routes/dns.ts: provider CRUD (admin), a "test connection"
  endpoint, and zone/record browsing+sync+CRUD (operator+), all audit-logged.
- dns_zones_cache/dns_records_cache tables replace Sloth Manager's
  dns-cache.json file, keeping the same "cache is the source of truth for
  display, sync fetches fresh from the provider" behavior.
- web: a DNS page with provider management, zone browsing, and a record
  editor, plus a reusable dynamic provider-config form.

Verified: full build (tsc + vite) passes; a scripted HTTP-layer test against
a running server exercises auth, role gating (403 for viewer), validation
(400 on missing config fields), provider CRUD, credential non-leakage in
list responses, and adapter error propagation (502 against an unreachable
host) — all passing. Real provider connectivity still needs to be checked
against the user's actual DNS accounts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5 committed 2026-09-14 23:00:30 +02:00
1 parent 89919fdbff
commit 39b1d1fe2e
24 files changed
+2726 -33

No files matched your search

@@ -25,16 +25,27 @@ CREATE TABLE `dns_providers` (
CREATE TABLE `dns_records_cache` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`provider_id` integer NOT NULL,
`zone` text NOT NULL,
`record_type` text NOT NULL,
`zone_id` text NOT NULL,
`record_id` text NOT NULL,
`type` text NOT NULL,
`name` text NOT NULL,
`value` text NOT NULL,
`content` text NOT NULL,
`ttl` integer,
`raw` text,
`synced_at` text DEFAULT (current_timestamp) NOT NULL,
`priority` integer,
`proxied` integer,
FOREIGN KEY (`provider_id`) REFERENCES `dns_providers`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `dns_zones_cache` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`provider_id` integer NOT NULL,
`zone_id` text NOT NULL,
`zone_name` text NOT NULL,
`synced_at` text,
FOREIGN KEY (`provider_id`) REFERENCES `dns_providers`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `dns_zones_cache_provider_zone_idx` ON `dns_zones_cache` (`provider_id`,`zone_id`);--> statement-breakpoint
CREATE TABLE `integration_credentials` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`name` text NOT NULL,
+90 -16
View File
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "1480fe39-d215-4e92-aee3-4de44905a67d",
"id": "19306643-f6f6-49dc-842a-ac2958e4d93a",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"audit_log": {
@@ -184,15 +184,22 @@
"notNull": true,
"autoincrement": false
},
"zone": {
"name": "zone",
"zone_id": {
"name": "zone_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"record_type": {
"name": "record_type",
"record_id": {
"name": "record_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
@@ -205,8 +212,8 @@
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true,
@@ -219,20 +226,19 @@
"notNull": false,
"autoincrement": false
},
"raw": {
"name": "raw",
"type": "text",
"priority": {
"name": "priority",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"synced_at": {
"name": "synced_at",
"type": "text",
"proxied": {
"name": "proxied",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(current_timestamp)"
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
@@ -255,6 +261,74 @@
"uniqueConstraints": {},
"checkConstraints": {}
},
"dns_zones_cache": {
"name": "dns_zones_cache",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"provider_id": {
"name": "provider_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"zone_id": {
"name": "zone_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"zone_name": {
"name": "zone_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"synced_at": {
"name": "synced_at",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"dns_zones_cache_provider_zone_idx": {
"name": "dns_zones_cache_provider_zone_idx",
"columns": [
"provider_id",
"zone_id"
],
"isUnique": true
}
},
"foreignKeys": {
"dns_zones_cache_provider_id_dns_providers_id_fk": {
"name": "dns_zones_cache_provider_id_dns_providers_id_fk",
"tableFrom": "dns_zones_cache",
"tableTo": "dns_providers",
"columnsFrom": [
"provider_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"integration_credentials": {
"name": "integration_credentials",
"columns": {
+2 -2
View File
@@ -5,8 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1789415495200,
"tag": "0000_tricky_nocturne",
"when": 1789419241921,
"tag": "0000_colossal_violations",
"breakpoints": true
}
]