Replace mapdns with daemon DNS

Serve daemon-managed .vm names directly from bangerd on 127.0.0.1:42069 instead of shelling out to mapdns. This keeps DNS state tied to VM lifecycle and lets the daemon rebuild records from running VMs after startup or reconcile.

Add a small in-process authoritative DNS server, register and remove records from the VM start/stop/delete paths, and show the listener in daemon status. Remove the mapdns config and preflight surface, stop helper-flow DNS publishing in customize.sh and interactive.sh, drop dns.sh from the runtime bundle, and update docs/tests for the new local-resolver integration model.

Validated with GOCACHE=/tmp/banger-gocache go test ./..., GOCACHE=/tmp/banger-gocache make build, and bash -n customize.sh interactive.sh.
This commit is contained in:
Thales Maciel 2026-03-17 15:49:35 -03:00
parent 430f66d5dd
commit 0a0b0b617b
No known key found for this signature in database
GPG key ID: 33112E6833C34679
24 changed files with 576 additions and 278 deletions

View file

@ -2,8 +2,6 @@ package daemon
import (
"context"
"os"
"path/filepath"
"strings"
"banger/internal/model"
@ -19,7 +17,6 @@ func (d *Daemon) validateStartPrereqs(ctx context.Context, vm model.VMRecord, im
checks.RequireCommand(command, toolHint(command))
}
checks.RequireExecutable(d.config.FirecrackerBin, "firecracker binary", hint)
checks.RequireExecutable(d.config.MapDNSBin, "mapdns binary", `install mapdns or set "mapdns_bin" / BANGER_MAPDNS_BIN`)
checks.RequireFile(image.RootfsPath, "rootfs image", "select a valid image or rebuild the runtime bundle")
checks.RequireFile(image.KernelPath, "kernel image", `set "default_kernel" or refresh the runtime bundle`)
if strings.TrimSpace(image.InitrdPath) != "" {
@ -33,14 +30,6 @@ func (d *Daemon) validateStartPrereqs(ctx context.Context, vm model.VMRecord, im
if vm.Spec.NATEnabled {
d.addNATPrereqs(ctx, checks)
}
if dataFile := strings.TrimSpace(d.config.MapDNSDataFile); dataFile != "" {
parent := filepath.Dir(dataFile)
if parent != "." && parent != "" {
if _, err := os.Stat(parent); err != nil && !os.IsNotExist(err) {
checks.Addf("mapdns data directory %s is not accessible (%v)", parent, err)
}
}
}
return checks.Err("vm start preflight failed")
}
@ -52,7 +41,6 @@ func (d *Daemon) validateImageBuildPrereqs(ctx context.Context, baseRootfs, kern
checks.RequireCommand(command, toolHint(command))
}
checks.RequireExecutable(d.config.CustomizeScript, "customize.sh helper", hint)
checks.RequireExecutable(d.config.MapDNSBin, "mapdns binary", `install mapdns or set "mapdns_bin" / BANGER_MAPDNS_BIN`)
checks.RequireFile(baseRootfs, "base rootfs image", `pass --base-rootfs or set "default_base_rootfs"`)
checks.RequireFile(kernelPath, "kernel image", `pass --kernel or set "default_kernel"`)
if strings.TrimSpace(initrdPath) != "" {
@ -109,8 +97,6 @@ func toolHint(command string) string {
return "install jq"
case "sha256sum":
return "install coreutils"
case "mapdns":
return `install mapdns or set "mapdns_bin" / BANGER_MAPDNS_BIN`
case "ssh":
return "install openssh-client"
case "bash":