mirror of
https://github.com/DevVoxel/vectordns-server.git
synced 2026-02-27 01:40:12 +00:00
62 lines
1.5 KiB
Markdown
62 lines
1.5 KiB
Markdown
# VectorDNS Go Server
|
|
|
|
A lightweight Go DNS lookup microservice powered by Chi and miekg/dns.
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Copy env config
|
|
cp .env.example .env
|
|
|
|
# Install dependencies
|
|
go mod tidy
|
|
|
|
# Run the server
|
|
go run ./cmd/server
|
|
```
|
|
|
|
The server starts on `http://localhost:8080`.
|
|
|
|
## Endpoints
|
|
|
|
| Method | Path | Description |
|
|
|--------|------|-------------|
|
|
| GET | `/healthz` | Health check |
|
|
| POST | `/api/v1/dns/lookup` | DNS record lookup |
|
|
|
|
### DNS Lookup
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/v1/dns/lookup \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"domain": "example.com", "types": ["A", "MX"]}'
|
|
```
|
|
|
|
If `types` is omitted, all 9 record types are queried (A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SRV).
|
|
|
|
## Configuration
|
|
|
|
All config is via environment variables (or `.env` file):
|
|
|
|
| Variable | Default | Description |
|
|
|----------|---------|-------------|
|
|
| `PORT` | `8080` | Server port |
|
|
| `API_KEY` | (empty) | API key for auth (disabled if empty) |
|
|
| `CORS_ORIGINS` | `http://localhost:3000` | Comma-separated allowed origins |
|
|
| `LOG_FORMAT` | `text` | `text` or `json` |
|
|
|
|
## Docker
|
|
|
|
```bash
|
|
docker build -t vectordns-server .
|
|
docker run -p 8080:8080 --env-file .env vectordns-server
|
|
```
|
|
|
|
## Tech Stack
|
|
|
|
- **Router**: [Chi v5](https://github.com/go-chi/chi)
|
|
- **DNS**: [miekg/dns](https://github.com/miekg/dns)
|
|
- **Logging**: stdlib `log/slog`
|
|
- **Rate Limiting**: [go-chi/httprate](https://github.com/go-chi/httprate)
|
|
- **CORS**: [go-chi/cors](https://github.com/go-chi/cors)
|