initial implementation #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Full Spec — Managed DNS Daemon (Port 53, SQLite, OpenRPC, Role-Pattern Auth)
0. Purpose
Build a minimal, production-grade DNS daemon that:
The system is a managed DNS server, not just a stub resolver.
1. High-Level Architecture
2. Core Features
2.1 DNS Serving
2.2 Management
OpenRPC over UDS only
Full CRUD for:
Runtime updates without restart
2.3 Storage
2.4 Forwarding
2.5 Authorization
3. Authorization Model (FULL WORKFLOW)
3.1 Principle
3.2 Request Flow
3.3 Claims (Input)
Each OpenRPC request includes:
3.4 Rules (Stored per Zone)
Each zone has:
3.5 Authorization Decision
A request is allowed if:
3.6 Matching Semantics
Rules:
*matches any suffixExamples
3.7 Matching Algorithm
3.8 Enforcement Scope
Authorization is checked:
👉 ONLY at zone level
Never per record.
3.9 Operations Requiring Authorization
3.10 Public Operations
No auth required:
DNS queries (UDP/TCP)
OpenRPC:
3.11 Default Behavior
4. DNS Engine
4.1 Query Flow
4.2 Response Codes
Must support:
4.3 Record Types (Required)
4.4 TTL Handling
5. Zones
5.1 Structure
Each zone:
5.2 Matching
Longest suffix match:
5.3 Zone Operations
6. Records
6.1 Fields
6.2 Typed Storage
Examples:
6.3 Operations
create/update/delete
enable/disable
list by:
7. Forwarders
7.1 Types
Standard DNS
Peer Node
7.2 Behavior
7.3 System Resolver Fallback
Optional:
7.4 Policy Modes
8. Listeners
8.1 Default
8.2 Configurable via OpenRPC
8.3 UDS
9. OpenRPC API
9.1 Transport
9.2 Modules
9.3 Example Methods
Zones
Records
Forwarders
Listeners
Queries
10. SQLite Schema
Tables
Zones Table
Records Table
11. Runtime Behavior
11.1 Dynamic Updates
No restart required for:
11.2 Cache
11.3 Logging
12. Networking
12.1 Protocols
12.2 IPv4 + IPv6 required
13. Validation
Must validate:
14. Default Bootstrap
On first run:
15. Acceptance Criteria
DNS
Auth
API
Persistence
16. Final Design Philosophy
This system is:
17. SKILLS to be used to implement this
/hero_crates_best_practices_check
/hero_proc_service_selfstart
/hero_sockets
Implementation Spec for Issue #1 — Managed DNS Daemon
Objective
Build a minimal, production-grade DNS daemon in Rust that serves authoritative DNS queries from a SQLite-backed zone store, supports forwarding (standard DNS and peer nodes), exposes an OpenRPC management API over Unix Domain Sockets, implements stateless role-pattern authorization, and supports full runtime reconfiguration without restart.
Requirements
Project Structure
Implementation Plan (11 Steps)
Step 1: Workspace Scaffold and Core Dependencies
Create Rust workspace with all crate skeletons and Cargo.toml configurations.
Dependencies: none
Step 2: SDK Domain Models, Record Types, and Validation
Define all shared types in my_dns_sdk (Zone, Record, Forwarder, Listener, AuthRule, RecordType enum, validation functions).
Dependencies: Step 1
Step 3: SDK Protocol, Socket, and Client Types
JSON-RPC 2.0 protocol types, UDS socket path resolution, async OpenRPC client.
Dependencies: Step 1
Step 4: SQLite Database Layer
Complete storage layer with schema creation, CRUD operations for all entities, and bootstrap logic.
Dependencies: Step 2
Step 5: DNS Engine — Authoritative Query Handler
Core DNS server using hickory-server that answers authoritative queries from SQLite zone store. Wildcard matching, CNAME chasing, cache.
Dependencies: Step 4
Step 6: DNS Forwarding Engine
Forwarding to upstream DNS servers and peer nodes with priority, fallback, and policy enforcement.
Dependencies: Step 5
Step 7: OpenRPC IPC Server and Method Dispatch
UDS-based JSON-RPC 2.0 server with all API method handlers for zones, records, forwarders, listeners, queries, system, health.
Dependencies: Step 4
Step 8: Authorization Layer
Stateless role-pattern authorization enforcement on all mutation RPC methods.
Dependencies: Step 7
Step 9: Bootstrap, Main Entry Point, and Runtime Lifecycle
Wire everything together in main.rs with startup sequence, signal handling, graceful shutdown.
Dependencies: Steps 5, 6, 7, 8
Step 10: CLI Client
Management CLI communicating with daemon via UDS OpenRPC.
Dependencies: Step 3
Step 11: Integration Tests and Documentation
Comprehensive integration tests covering all features.
Dependencies: Step 9, 10
Acceptance Criteria
cargo build --workspace --releaseTest Results
Breakdown
my_dns_sdk: 90 tests (models, record types, validation, protocol, auth, socket)my_dns_server: 58 tests (database CRUD, cache, IPC handlers)my_dns_cli: 0 tests (CLI binary)All tests pass.
cargo check --workspacecompiles cleanly.Implementation Summary
Crates Created
my_dns_sdk (shared library)
models.rs— Domain types: Zone, Record, Forwarder, Listener, GlobalConfig with enums for ForwardPolicy, ForwarderType, ListenerProtocolrecord_types.rs— All 19 DNS record types (A, AAAA, CNAME, NS, MX, TXT, SRV, PTR, SOA, CAA, NAPTR, TLSA, DNSKEY, DS, SSHFP, LOC, SPF, HINFO, RP)validate.rs— Validation for zone names, record data, TTL, forwarder endpoints, listener configs, auth rulesprotocol.rs— JSON-RPC 2.0 types (RpcRequest, RpcResponse, RpcError) with standard and custom error codessocket.rs— UDS path resolution (env var > system > user)auth.rs— Claims parsing from Bearer tokens, hierarchical dot-separated rule matching with wildcard supportclient.rs— Async OpenRPC client over UDSresponses.rs— API response typesconfig.rs— Server configuration typesversion.rs— Version infomy_dns_server (daemon binary)
db/— SQLite storage layer with full CRUD for zones, records, forwarders, listeners, global_config. Bootstrap seeding on first run.dns/handler.rs— Core DNS handler implementing hickory-server RequestHandler. Longest-suffix zone matching, wildcard records, CNAME chasing, cache integration.dns/server.rs— DNS server wrapper binding UDP+TCP listenersdns/cache.rs— TTL-based in-memory cache with DashMapdns/forwarding.rs— Forward resolver with priority-based fallback using hickory-resolveripc/server.rs— UDS JSON-RPC 2.0 server with method dispatch and auth extractionipc/handlers/— All RPC method handlers (zones, records, forwarders, listeners, queries, system, health)main.rs— Entry point with clap CLI, bootstrap, IPC+DNS server startup, graceful shutdownmy_dns_cli (management CLI)
Key Features Implemented
Test Results
Implementation committed:
93fcd15Browse:
93fcd15