Refactor parsers to Superpower; config set; EnsureManagedConfig; options doc

- Parsers: Superpower for all (Directive, FileLine, Include, DhcpHost, Leases, Hosts)
- Shared ConfParserHelpers (Token, OptionalCommentPrefix)
- DnsmasqConfOptionRegistry + DnsmasqOptionKind: typed options (ConfFile, ConfDir,
  Domain, DhcpRange, Server, Local, Address, DhcpOption, DhcpHost, Path, Flag, etc.)
- EnsureManagedConfigHostedService: append conf-dir= to main config if missing,
  then create managed file; DnsmasqOptions + Dockerfile comments for permissions
- Renames: ConfigLine->DnsmasqConfLine, ConfigSet->DnsmasqConfigSet, etc.
- Test harness: entrypoint in scripts/, prepare-test-mount improvements
- Status/Reload API and UI: stdout+stderr, exit code
This commit is contained in:
2026-01-31 19:28:10 +10:00
parent f5bbe7d608
commit 40fbf14327
49 changed files with 2260 additions and 521 deletions
-15
View File
@@ -1,15 +0,0 @@
# Test data
Used in two ways:
1. **Unit tests** – Parsers and services read from `testdata/` (e.g. `testdata/leases` for lease-format tests).
2. **Docker test harness** – Run `scripts/prepare-test-mount.sh` to copy this into `testdata-mount/` (gitignored). Compose mounts `testdata-mount` as `/data`. **leases** is excluded from the copy so dnsmasq creates and owns the real leases file in the harness.
Files:
- **hosts** – Shared by app and dnsmasq (read/write by app, `addn-hosts` for dnsmasq).
- **dnsmasq.conf** – Sample main config (reference only; not used by the test containers).
- **dnsmasq-test.conf** – Config for dnsmasq when run inside the app container (DHCP-only, paths under `/data`).
- **dnsmasq.d/dhcp.conf** – DHCP static hosts; app edits this, dnsmasq loads it via `conf-dir`.
- **dnsmasq.d/01-other.conf** – Other snippet (not managed by app).
- **leases** – For **unit tests only**. In the Docker harness, dnsmasq creates `/data/leases`; the app watches it and shows live leases.
+24
View File
@@ -0,0 +1,24 @@
# Reference: dnsmasq config example (format only).
# Source: https://github.com/imp/dnsmasq/blob/master/dnsmasq.conf.example
# Format: one option per line; same as long options without "--". See "man 8 dnsmasq".
# Option categories we care about for parsing:
# Include: conf-file=, conf-dir=
# Paths: addn-hosts=, resolv-file=, dhcp-leasefile=, dhcp-hostsfile=
# Simple: domain=, port=, user=, group=, interface=, listen-address=
# Flags: domain-needed, bogus-priv, no-hosts, expand-hosts, strict-order
# DHCP: dhcp-range=..., dhcp-host=..., dhcp-option=..., dhcp-leasefile=
# Server: server=/domain/ip, local=/domain/
# Other: address=, cache-size=, local-ttl=, log-queries, etc.
#conf-file=/etc/dnsmasq.more.conf
#conf-dir=/etc/dnsmasq.d
#addn-hosts=/etc/banner_add_hosts
#domain=thekelleys.org.uk
#dhcp-range=192.168.0.50,192.168.0.150,12h
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
#dhcp-leasefile=/var/lib/misc/dnsmasq.leases
#server=/localnet/192.168.0.1
#local=/localnet/
#address=/double-click.net/127.0.0.1