Status: Under Active Development 🚧
A high-performance DNS server written in Rust, reimagining mosdns with modern async Rust architecture.
- ⚡ High Performance: Built on Tokio async runtime with 8 worker threads
- 🔌 Plugin Architecture: Extensible plugin system for custom DNS processing logic
- 🌐 Multiple Protocols: Support for UDP, TCP, DoT, DoQ, and DoH
- 🔄 Connection Pooling: Advanced connection management with pipelining and reuse strategies
- 📊 Smart Logging: Structured logging with configurable levels and optional file output
- ⏱️ Efficient Time Tracking: Lock-free application clock for hot-path performance
- UDP: Standard DNS over UDP (port 53)
- TCP: DNS over TCP (port 53) with optional pipelining
- DoT: DNS over TLS (port 853)
- DoQ: DNS over QUIC (port 853)
- DoH: DNS over HTTPS via HTTP/2 or HTTP/3 (port 443)
forgedns/
├── src/
│ ├── main.rs # Entry point and runtime setup
│ ├── core/ # Core infrastructure
│ │ ├── runtime.rs # CLI argument parsing
│ │ ├── log.rs # Custom log formatter
│ │ ├── app_clock.rs # High-performance clock
│ │ └── context.rs # DNS request/response context
│ ├── config/ # Configuration management
│ │ └── config.rs # YAML config structures
│ ├── plugin/ # Plugin system
│ │ ├── server/ # Server plugins (UDP, TCP)
│ │ └── executable/ # Executor plugins (forward, filter)
│ └── pkg/
│ └── upstream/ # Upstream DNS resolver
│ ├── bootstrap.rs # Bootstrap DNS resolution
│ └── pool/ # Connection pooling
│ ├── udp_conn.rs
│ ├── tcp_conn.rs
│ ├── quic_conn.rs
│ ├── h2_conn.rs
│ ├── h3_conn.rs
│ ├── pipeline.rs # Pipeline connection pool
│ └── reuse.rs # Reuse connection pool
└── config.yaml # Server configuration
- Lock-Free Design: Atomic operations for hot paths (request mapping, clock)
- Connection Reuse: Amortizes handshake costs across multiple requests
- Request Pipelining: Multiple concurrent requests per TCP/TLS connection
- Efficient Time Tracking: Background task updates time every 1ms for zero-syscall reads
- Zero-Copy: Minimizes allocations and copies where possible
- Automatic Scaling: Connection pools grow/shrink based on load
cargo build --release# Use default config.yaml
./target/release/forgedns
# Specify custom config
./target/release/forgedns -c /path/to/config.yaml
# Override log level
./target/release/forgedns -l debugSee config.yaml for configuration examples. The config supports:
- Logging: Level (off/trace/debug/info/warn/error) and optional file output
- Plugins: List of plugins with type-specific configurations
udp_server: UDP DNS server listenerforward: DNS forwarding to upstream resolvers
GPL-3.0-or-later
Sven Shi isvenshi@gmail.com