Skip to content

virchich/codecrafters-dns-server-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNS Server in Rust

This is my Rust implementation of the CodeCrafters Build Your Own DNS Server challenge.

The project is intentionally small, but it covers the core pieces of a DNS server: parsing DNS packets from UDP, decoding compressed question names, encoding DNS responses, forwarding queries to an upstream resolver, and generating mock A-record answers for challenge stages that allow synthetic responses.

What It Demonstrates

  • DNS wire-format parsing and serialization without a DNS library.
  • Rust ownership around borrowed packet buffers and encoded response buffers.
  • Typed errors with thiserror and application-level error propagation with anyhow.
  • A bounded, standard-library worker pool for concurrent UDP request handling.
  • Structured logging with tracing.
  • Unit tests for packet encoding/decoding, compressed names, response construction, handler behavior, provider behavior, CLI parsing, and worker configuration.

Running

cargo run -- --local-addr 127.0.0.1:2053 --resolver 8.8.8.8:53

Optional concurrency settings:

cargo run -- --workers 4 --queue-capacity 128

Logging can be controlled with RUST_LOG:

RUST_LOG=debug cargo run

Verification

cargo test
cargo clippy --all-targets --all-features -- -D warnings

Notes

This is a learning project, not a production DNS server. It supports the subset of DNS needed for the CodeCrafters challenge. One challenge-specific behavior is called out in code: when an upstream resolver fails, the handler falls back to synthetic A records because some CodeCrafters stages accept mocked answers.

About

DNS server in Rust built through CodeCrafters; DNS packet parsing, compression, UDP forwarding, worker pool, and tests.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors