Add DoH server blocklist: curated feeds, canary probe, router reconciliation (D-0054) #133

Merged
hannah-vernon merged 1 commit from feature/doh-blocklist into dev 2026-09-24 14:16:18 -05:00
Owner

What does this PR do?

Adds a DoH-server blocklist feature that keeps the pre-existing dns_over_https_servers MikroTik address list current on every managed router, so the firewall can block DNS-over-HTTPS resolvers that bypass local DNS controls.

Three cooperating workers:

  • Feed fetch downloads curated DoH IPv4 feeds (dibdot primary, optional secondary), parses IPv4/CIDR entries, and replaces the desired-address snapshot. Feeds are authoritative for inclusion.
  • Canary probe sends a DNS-over-HTTPS TXT query by IP to an operator-owned FQDN and classifies each candidate. Confirmed requires HTTP 200 + application/dns-message + the published token. The probe is confirmation-only annotation; it never deletes an entry on its own.
  • Reconciliation full-syncs the owned address list on each enabled router (add/remove plus per-entry comment via the RouterOS REST PATCH).

Follows the existing config-store pattern (D-0050..D-0053): single-row settings plus desired-address and probe-result tables, in-memory + Postgres stores, options-fallback source, create-only seed worker, NOTIFY-based refresh, EF migration, step-up-gated audited write at /configuration#doh-blocklist, and read-only GET /api/v1/doh/settings. Every control is editable in the Admin UI and readable via the API.

Router writes are propose-only until ApplyToRouters is enabled and global dry-run is off. v1 is IPv4-only, matching the existing IPv4 firewall list. The probe client tolerates certificate mismatch because it connects by IP and the canary token is public, so no secret is exposed.

See DECISIONS.md D-0054 for the full rationale and rejected alternatives.

How was this tested?

  • dotnet build - 0 errors, 0 warnings
  • dotnet test - AdminApi 225, Application 581 (17 new DoH tests), Postgres integration 88, all pass
  • Manually tested on ___ (pending deploy; router PATCH path exercised against live RouterOS after merge)

Checklist

  • I have read the Contributing Guide
  • Changes are focused - one logical change per PR
  • Documentation updated (DECISIONS.md D-0054, AGENT-README.md, ARCHITECTURE.md)
  • New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md (no new dependencies added)
  • No secrets, credentials, or real infrastructure identifiers in the diff
  • No commented-out code or debug leftovers
## What does this PR do? Adds a DoH-server blocklist feature that keeps the pre-existing `dns_over_https_servers` MikroTik address list current on every managed router, so the firewall can block DNS-over-HTTPS resolvers that bypass local DNS controls. Three cooperating workers: - **Feed fetch** downloads curated DoH IPv4 feeds (dibdot primary, optional secondary), parses IPv4/CIDR entries, and replaces the desired-address snapshot. Feeds are authoritative for inclusion. - **Canary probe** sends a DNS-over-HTTPS TXT query by IP to an operator-owned FQDN and classifies each candidate. `Confirmed` requires HTTP 200 + `application/dns-message` + the published token. The probe is confirmation-only annotation; it never deletes an entry on its own. - **Reconciliation** full-syncs the owned address list on each enabled router (add/remove plus per-entry comment via the RouterOS REST `PATCH`). Follows the existing config-store pattern (D-0050..D-0053): single-row settings plus desired-address and probe-result tables, in-memory + Postgres stores, options-fallback source, create-only seed worker, NOTIFY-based refresh, EF migration, step-up-gated audited write at `/configuration#doh-blocklist`, and read-only `GET /api/v1/doh/settings`. Every control is editable in the Admin UI and readable via the API. Router writes are propose-only until `ApplyToRouters` is enabled and global dry-run is off. v1 is IPv4-only, matching the existing IPv4 firewall list. The probe client tolerates certificate mismatch because it connects by IP and the canary token is public, so no secret is exposed. See DECISIONS.md D-0054 for the full rationale and rejected alternatives. ## How was this tested? - [x] `dotnet build` - 0 errors, 0 warnings - [x] `dotnet test` - AdminApi 225, Application 581 (17 new DoH tests), Postgres integration 88, all pass - [ ] Manually tested on ___ (pending deploy; router PATCH path exercised against live RouterOS after merge) ## Checklist - [x] I have read the [Contributing Guide](../CONTRIBUTING.md) - [x] Changes are focused - one logical change per PR - [x] Documentation updated (DECISIONS.md D-0054, AGENT-README.md, ARCHITECTURE.md) - [x] New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md (no new dependencies added) - [x] No secrets, credentials, or real infrastructure identifiers in the diff - [x] No commented-out code or debug leftovers
Keep the pre-existing dns_over_https_servers MikroTik address list current on
every managed router so the firewall can block DNS-over-HTTPS resolvers that
bypass local DNS controls.  Three stages: DohFeedFetchWorker downloads curated
DoH IPv4 feeds (dibdot primary, optional secondary), parses IPv4/CIDR entries,
and replaces the desired-address snapshot; DohProbeWorker sends a canary DoH TXT
query by IP and classifies each candidate (Confirmed requires HTTP 200 +
application/dns-message + the published token) as confirmation-only annotation;
DohReconciliationWorker full-syncs the owned address list on each enabled router
(add/remove plus per-entry comment via RouterOS REST PATCH).

Follows the D-0050..D-0053 config-store pattern: single-row doh_blocklist_settings
plus doh_desired_addresses and doh_probe_results tables, in-memory + Postgres
stores, DohBlocklistSettingsSource with options fallback, create-only seed worker,
viegard_config_doh_blocklist_settings NOTIFY refresh, EF migration, step-up-gated
audited write on /configuration#doh-blocklist, and read-only GET /api/v1/doh/settings.
Every control is editable in the Admin UI and readable via the API.  Router writes
are propose-only until ApplyToRouters is enabled and global dry-run is off.  v1 is
IPv4-only.  The probe client tolerates certificate mismatch (probing by IP; the
canary token is public).

Tests: 17 new unit tests (feed parse, canary query/token, validator, settings
store concurrency, feed fetch, reconciliation add/remove/comment/dry-run/disabled).
Full build 0/0; AdminApi 225, Application 581, Postgres integration 88 all pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hannah-vernon/viegard-sentinel!133
No description provided.