docs(homelab): introduce pluggable DDNS connector architecture for Cloudflare and Dynu
Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 7s
Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 7s
Update dynu-monitor plan and discussion to define the decoupled DdnsConnector trait, supporting both Dynu and Cloudflare providers.
This commit is contained in:
1 parent
2f1d87c599
commit
9577375ff7
2 files changed
+42
-12
No files matched your search
@@ -56,6 +56,35 @@ Rather than merging the intermediate Python rewrite into `Core`, the preferred a
|
||||
|
||||
## 4. Architectural Invariants for the Rust Implementation
|
||||
|
||||
1. **Gatekeeper Pattern**: `dynu-monitor` only triggers `ddclient.service` when a public IP change is verified.
|
||||
2. **Update Confirmation**: `last_ip` in `state.json` is updated **only after** `ddclient` exits successfully. A failed update preserves the previous IP so retries continue.
|
||||
1. **Gatekeeper Pattern**: `ddns-monitor` only triggers the configured DDNS provider connector when a public IP change is verified.
|
||||
2. **Update Confirmation**: `last_ip` in `state.json` is updated **only after** the provider update succeeds. A failed update preserves the previous IP so retries continue.
|
||||
3. **Graceful Resolver Failover**: If the current provider in the round-robin sequence fails or times out (5s), the daemon falls back to the next provider immediately without failing the tick.
|
||||
|
||||
---
|
||||
|
||||
## 5. Provider Decoupling & Rebrand to `ddns-monitor`
|
||||
|
||||
### The Catalyst: Dynu Quota Constraints vs. Cloudflare
|
||||
During the Homelab email server and DKIM setup, a fundamental upstream constraint was encountered: **Dynu limits free accounts to 4 custom CNAME/alias records**. While sufficient for minimal setups, scaling the homelab with service subdomains, transactional email relays (Brevo/SES), and verification tokens creates friction unless paying for Dynu Membership ($9.99/yr).
|
||||
|
||||
In contrast, **Cloudflare DNS** provides:
|
||||
* 100% free, unlimited DNS records, CNAMEs, and TXT entries.
|
||||
* Global anycast sub-second DNS propagation.
|
||||
* Robust public REST API (native Traefik DNS-01 and DDNS automation).
|
||||
|
||||
### The Connector Pattern Architecture
|
||||
Rather than hardcoding the daemon to Dynu, the project is renamed from `dynu-monitor` to **`ddns-monitor`** and implements a pluggable **Connector / Adapter pattern**:
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
Core["ddns-monitor (Domain Core)<br/>• 30s Polling Loop<br/>• 5-Provider Echo Rotation<br/>• State Tracking (last_ip)"] -->|Trait Contract| Trait["Box<dyn DdnsConnector>"]
|
||||
Trait --> Dynu["DynuConnector<br/>(Dynu REST API / ddclient)"]
|
||||
Trait --> Cloudflare["CloudflareConnector<br/>(Cloudflare API v4)"]
|
||||
Trait --> Mock["MockConnector<br/>(In-memory Test Double)"]
|
||||
```
|
||||
|
||||
### Benefits of the Decoupled Design
|
||||
1. **Zero-Downtime Provider Migration**: Switching from Dynu to Cloudflare simply requires swapping the connector in configuration without altering IP detection, history tracking, or systemd daemon structure.
|
||||
2. **Isolated Credentials**: Each connector manages its own authentication (e.g. `DynuCredentials` vs `CloudflareApiToken`), passed cleanly via SOPS templates.
|
||||
3. **Multi-Provider Sync**: The core can support a `CompositeConnector` that simultaneously updates multiple DNS zones across providers if dual-routing is required.
|
||||
|
||||
@@ -10,13 +10,13 @@ tags:
|
||||
- migration
|
||||
---
|
||||
|
||||
# 🦀 Rust Daemon Migration Plan: Standalone `dynu-monitor`
|
||||
# 🦀 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 `/home/kiskaadee/Projects/active/dynu-monitor`.
|
||||
Migrate the dynamic DNS gatekeeper daemon from the current Python script to a native, statically compiled **Rust daemon** located at `/home/kiskaadee/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.
|
||||
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).
|
||||
|
||||
---
|
||||
|
||||
@@ -36,12 +36,12 @@ This implementation introduces high-frequency 30-second polling and stateful rou
|
||||
│
|
||||
┌────────────────┼────────────────┐
|
||||
▼ ▼ ▼
|
||||
Box<dyn IpResolver> Box<dyn StateRepo> Box<dyn DdnsUpdater>
|
||||
Box<dyn IpResolver> Box<dyn StateRepo> Box<dyn DdnsConnector>
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
HttpEchoPool StateFile Systemctl
|
||||
(5 endpoints) (state.json) (ddclient.service)
|
||||
│
|
||||
HttpEchoPool StateFile [Pluggable Connectors]
|
||||
(5 endpoints) (state.json) ├── DynuConnector (REST / ddclient)
|
||||
│ └── CloudflareConnector (API v4)
|
||||
▼
|
||||
HistoryFile
|
||||
(ip_history.jsonl)
|
||||
@@ -63,17 +63,18 @@ This implementation introduces high-frequency 30-second polling and stateful rou
|
||||
### Milestone 1: Domain Entities & In-Memory Logic *(In Progress)*
|
||||
- [x] Define domain types: `Ipv4Addr`, `ProviderId`, `MonitorEvent`.
|
||||
- [ ] Implement `IpMonitorService` pure business logic.
|
||||
- [ ] Mock traits `MockIpResolver`, `MockStateRepository`, `MockDdnsUpdater`.
|
||||
- [ ] Mock traits `MockIpResolver`, `MockStateRepository`, `MockDdnsConnector`.
|
||||
- [ ] Unit tests verifying:
|
||||
- No change detected $\rightarrow$ zero updater calls.
|
||||
- Change detected $\rightarrow$ updater triggered $\rightarrow$ state updated.
|
||||
- Updater fails $\rightarrow$ state remains unchanged.
|
||||
|
||||
### Milestone 2: Infrastructure Adapters (HTTP, File, Systemd)
|
||||
### Milestone 2: Infrastructure Adapters & Provider Connectors
|
||||
- [ ] Implement `ReqwestIpResolver` with 5-endpoint pool (`ipify`, `icanhazip`, `ifconfig.me`, `checkip.dynu`, `wtfismyip`).
|
||||
- [ ] Implement `JsonStateRepository` with atomic write (write to `.tmp` then rename).
|
||||
- [ ] Implement `JsonlHistoryRepository` for append-only audit logs.
|
||||
- [ ] Implement `SystemdDdnsUpdater` calling `systemctl start ddclient.service`.
|
||||
- [ ] Implement `DynuConnector` calling `systemctl start ddclient.service` or Dynu REST API.
|
||||
- [ ] Implement `CloudflareConnector` querying Cloudflare API v4 for zero-quota DNS record updates.
|
||||
|
||||
### Milestone 3: Nix Packaging & Flake Integration
|
||||
- [ ] Write `flake.nix` in `Projects/active/dynu-monitor` producing a static package.
|
||||
|
||||
Reference in new issue
Block a user