Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s
relative links - Update all Homelab documents and engineering journals with core tags (`architecture`, `security`, `operations`, `ADR`). - Replace machine-specific `file:///` URLS and absolute local paths with portable relative Markdown links and code backticks. - Align Homelab project landing page and documentation status with current infrastructure topology
4.3 KiB
4.3 KiB
type, status, project, tags
| type | status | project | tags | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| plan | active | homelab |
|
🦀 Rust Daemon Migration Plan: Standalone ddns-monitor (formerly dynu-monitor)
🎯 Goal Description
Migrate the dynamic DNS gatekeeper daemon from the current Python script to a native, statically compiled Rust daemon located at ~/Projects/active/ddns-monitor.
This implementation introduces high-frequency 30-second polling and stateful round-robin resolver rotation across 5 public echo providers while eliminating Python interpreter overhead on the headless server. Crucially, it decouples the DDNS update mechanism behind a pluggable DdnsConnector trait to support both Dynu and Cloudflare (overcoming Dynu's free-tier 4-alias quota limit).
🏛️ Target Domain Architecture
┌────────────────────────┐
│ main.rs │
│ (Dependency Wiring) │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ IpMonitorService │
│ (Domain Core) │
└───────────┬────────────┘
│
┌────────────────┼────────────────┐
▼ ▼ ▼
Box<dyn IpResolver> Box<dyn StateRepo> Box<dyn DdnsConnector>
│ │ │
▼ ▼ ▼
HttpEchoPool StateFile [Pluggable Connectors]
(5 endpoints) (state.json) ├── DynuConnector (REST / ddclient)
│ └── CloudflareConnector (API v4)
▼
HistoryFile
(ip_history.jsonl)
🔒 Non-Negotiable Invariants
last_ipstrictly represents the IP address for which a DDNS update completed successfully.- Discovering a new IP does not update
last_ipuntilddclient.serviceexits with code 0. - A failed DDNS update preserves the previous
last_ipinstate.jsonto trigger a retry on the next tick. - Resolver queries must enforce a strict 5-second timeout to prevent stalling the monitoring loop.
🗺️ Phased Implementation Milestones
Milestone 1: Domain Entities & In-Memory Logic (In Progress)
- Define domain types:
Ipv4Addr,ProviderId,MonitorEvent. - Implement
IpMonitorServicepure business logic. - Mock traits
MockIpResolver,MockStateRepository,MockDdnsConnector. - Unit tests verifying:
- No change detected
\rightarrowzero updater calls. - Change detected
\rightarrowupdater triggered\rightarrowstate updated. - Updater fails
\rightarrowstate remains unchanged.
- No change detected
Milestone 2: Infrastructure Adapters & Provider Connectors
- Implement
ReqwestIpResolverwith 5-endpoint pool (ipify,icanhazip,ifconfig.me,checkip.dynu,wtfismyip). - Implement
JsonStateRepositorywith atomic write (write to.tmpthen rename). - Implement
JsonlHistoryRepositoryfor append-only audit logs. - Implement
DynuConnectorcallingsystemctl start ddclient.serviceor Dynu REST API. - Implement
CloudflareConnectorquerying Cloudflare API v4 for zero-quota DNS record updates.
Milestone 3: Nix Packaging & Flake Integration
- Write
flake.nixinProjects/active/dynu-monitorproducing a static package. - Package
dynu-monitorintohomelab-core/nixos/modules/dynu.nix. - Replace
ipMonitorScript = pkgs.writers.writePython3Bin ...with the native binary derivation.
Milestone 4: Production Deployment & Verification
- Deploy generation via
sudo nixos-rebuild switch --flake ~/Core#server. - Verify 30-second timer cadence and resolver rotation in
/var/lib/dynu/state.json. - Verify zero memory leaks or zombie processes.