Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

hepangda/chara

Repository files navigation

chara

 _____ _ _ ___ _____ ___
/ ___| | | | | / | | _ \ / |
| | | |_| | / /| | | |_| | / /| |
| | | _ | / / | | | _ / / / | |
| |___ | | | | / / | | | | \ \ / / | |
\_____| |_| |_| /_/ |_| |_| \_\ /_/ |_|

A high-performance DNS forwarding server with caching, IP speed testing, hot-reload configuration, and Prometheus metrics.

中文文档

Features

  • UDP + TCP DNS serving with SO_REUSEPORT
  • LRU cache with DNS TTL
  • Upstream failover (sequential retry), automatic TCP fallback on UDP truncation
  • Upstream health checks + circuit breaker (cooldown after N consecutive failures, half-open auto-recovery)
  • Background concurrent TCP-connect speed testing, returns only the fastest IP on cache hit
  • Hotspot domain warm-up on startup (concurrent queries, populates cache + triggers speed test)
  • Domain blacklist (exact + suffix matching)
  • Domain overrides (static A record responses)
  • Hotspot tracking + persistence
  • Hot-reload configuration (fsnotify + debounce)
  • Prometheus metrics at /metrics
  • Graceful shutdown (SIGINT/SIGTERM)

Project Structure

chara/
├── cmd/chara/ # Entry point
├── server/ # DNS server (UDP + TCP)
├── resolver/ # DNS resolution (speed filtering, hotspot warm-up)
├── forwarder/ # DNS forwarding
├── upstream/ # Upstream health checks + circuit breaker
├── cache/ # DNS cache
├── hotspot/ # Hotspot tracking
├── speedtest/ # IP speed testing
├── config/ # Configuration management
├── reloader/ # Hot-reload
├── metrics/ # Prometheus metrics
├── config.json # Example configuration
└── Dockerfile # Production image

Build & Run

go mod tidy
go build -o chara ./cmd/chara
sudo ./chara -c config.json

Test:

dig @127.0.0.1 -p 8053 example.com
curl http://127.0.0.1:9153/metrics | grep chara_

Docker

docker build -t chara .
docker run -p 8053:8053/udp -p 8053:8053/tcp -p 9153:9153 chara

Dev Container

Open the project in VS Code and select "Reopen in Container" to use the pre-configured Go development environment.

License

See LICENSE for details.

About

Chara: DNS Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /