dns-cash is designed to be a high-performance, multi-threaded DNS cache server. It features a modular architecture separating the server listener, request processor, and execution engine.
This project is currently incomplete and under active development. While the core infrastructure (server, threading, caching) is in place, the logic for handling DNS responses and forwarding is incomplete.
Also, at this moment, it heavily relies on Windows APIs and is non portable.
A personal experimental project implementing a DNS server in C++ adhering to RFC 1035.
- High-Performance UDP Server: Uses Windows Sockets (WSA) for handling UDP traffic.
- Thread Pool: Custom thread pool implementation for concurrent request processing.
- TLRU Cache: Time-Aware Least Recently Used cache to store DNS records with TTL support.
- DNS Parsing:
- Header Section Parsing
- Question Section Parsing
- Message Compression (RFC 1035 4.1.4) support
- Response Generation: Logic to construct and serialize DNS response packets.
- Upstream Forwarding:
- Handling responses from upstream resolvers (e.g., 8.8.8.8).
- Mapping upstream responses back to original client requests (Transaction ID matching).
- Full Packet Parsing: Parsing Answer, Authority, and Additional sections.
- Client Reply: Sending the resolved (or cached) answer back to the client.
- TCP Support: Fallback to TCP for large queries/responses (RFC 1035 requirement).
src/server: UDP server implementation (DNSServer).src/processor: DNS packet parsing and logic (dns_parser,dns_processor).src/executors: Concurrency management (ThreadPool).src/utils: Utility structures likeTLRUCacheand command-line parsing.src/callback: Request handling callbacks.
- CMake 3.10 or higher
- C++20 compatible compiler (e.g., MSVC, GCC, Clang)
mkdir out
cd out
cmake ..
cmake --build .Run the generated executable:
./dns-cashBy default, the server listens on port 6073.