kiskaadee 13d3240ba4 test(contracts): add verified Dynu Class A contract assertions and specification
- Add test_dynu_contract.py asserting reachability, auth errors, and idempotency
- Document empirical findings in docs/contracts/class-a-dynu.md
- Record Dynu-specific behaviors: bare nochg, unknown on empty call, and
  IP match short-circuiting prior to credential evaluation
2026-10-29 10:20:10 -05:00
2026-10-28 10:59:59 -05:00

ddns-monitor

A provider-agnostic Dynamic DNS monitor written in Rust.

Monitors the machine's public WAN IPv4 address and, when a change is detected, notifies all configured DDNS provider subscribers. Designed to replace ddclient on NixOS homelabs and to work on any standard Linux system.


Why this exists

DDNS updaters like ddclient couple the IP-detection step to a single provider. When that provider has an outage, the entire update chain breaks — even though your IP may not have changed and other providers could accept the update.

ddns-monitor:

  • Separates IP discovery (round-robin across multiple checkers) from DNS updating (fan-out to multiple DDNS provider plugins).
  • Stores the last-known-good IP locally and skips updates when nothing has changed.
  • Notifies all configured subscribers on a detected change.
  • Runs as a systemd oneshot timer, consuming no resources between invocations.

Status

Phases 0 through 8 Complete — v1 Ready. Full Rust implementation with domain models, round-robin WAN IP discovery via ureq (rustls), atomic JSON state persistence, JSONL execution history, native Dynu API updater plugin, multi-subscriber fan-out, and declarative NixOS systemd module.

See ROADMAP.md for details.


Quick Start (development)

Prerequisites: Nix with flakes enabled. No system OpenSSL required — TLS is handled by bundled rustls.

# Enter the development shell (downloads pinned Rust toolchain)
nix develop

# Build
cargo build

# Run tests
cargo nextest run

# Live-reload on save
cargo watch -x check

Architecture (target)

main.rs (composition root)
└── IpMonitorService (orchestration)
    ├── IpResolver      — discovers WAN IP via rotating external checkers
    ├── StateRepository — persists last-known-good IP as JSON
    ├── NotificationBus — fans out to all configured DDNS updaters
    │   ├── DynuUpdater       (Phase 6)
    │   └── «future plugins»
    └── HistoryRepository — append-only JSONL audit log

The application service contains all decision logic. Infrastructure components (HTTP, fs, subprocess) are hidden behind traits and swappable in tests.


Configuration

The binary reads from (in priority order):

  1. NixOS module options (declarative, build-time injection)
  2. ~/.config/ddns-monitor/config.toml (runtime, for non-NixOS)

Example:

[ip_providers]
urls = [
    "https://api.ipify.org",
    "https://ifconfig.me/ip",
    "https://icanhazip.com",
]
timeout_secs = 5

[[subscribers]]
provider = "dynu"
domain   = "example.dyndns.org"
credentials_env = "DYNU_PASSWORD"

Never store plaintext credentials in config.toml. Use env vars or sops-nix secrets.


NixOS

The NixOS module (Phase 8) will:

  • Build the binary as a Nix derivation.
  • Expose services.ddns-monitor.subscribers as a list of option sets.
  • Inject credentials from sops.secrets via LoadCredential.
  • Run as a oneshot systemd timer (30-minute default, configurable).

Invariants

  1. last_ip = the IP from the last fully successful fan-out (all subscribers succeeded).
  2. Discovering an IP does not update last_ip.
  3. A partial or total update failure leaves last_ip unchanged.
  4. The monitor does not fire DDNS when the discovered IP matches last_ip.
  5. Provider rotation state may be persisted independently of IP changes.
  6. All infrastructure dependencies are injectable via traits (testable without network/fs).

License

Unlicense — public domain.

S
Description
Lightweight daemon in Rust monitoring public IPv4 address changes and automatically updating Dynu DDNS records.
Readme
111 KiB
0 Stars 1 Watchers 0 Forks
Languages
Rust 69.6%
Python 20.1%
Nix 10.3%