manydns
A Rust library providing a provider-agnostic API for managing DNS zones and records.
Overview
manydns defines abstract traits for DNS zone and record management, with concrete implementations for multiple DNS providers. The API design is inspired by the Go libdns project, adapting its conventions for Rust idioms while maintaining familiar semantics for developers coming from that ecosystem.
Installation
Add manydns to your project with the provider you need:
[]
= { = "1.0", = ["cloudflare"] }
Quick Start
use ;
use CloudflareProvider;
async
Supported Providers
Enable providers via feature flags:
| Provider | Feature Flag | Zone Create/Delete |
|---|---|---|
| Cloudflare | cloudflare |
No |
| Hetzner DNS | hetzner |
Yes |
| DNSPod | dnspod |
No |
| Tencent Cloud | tencent |
No |
| Technitium | technitium-dns |
Yes |
| Namecheap | namecheap |
No |
| Namecrane | namecrane |
No |
Core Traits
The library uses a capability-based trait design:
// Provider: entry point for zone access
// Zone: record management within a zone
// Optional capabilities
Record Types
Supported DNS record types:
- A - IPv4 address
- AAAA - IPv6 address
- CNAME - Canonical name (alias)
- MX - Mail exchange
- NS - Name server
- TXT - Text record
- SRV - Service record
- Other - Pass-through for provider-specific types
Record Naming Convention
Record names are relative to the zone, following the same convention as Go libdns:
"www"refers towww.example.comin zoneexample.com"@"refers to the zone apex (example.comitself)"sub.domain"refers tosub.domain.example.com
Network Configuration
All providers support HttpClientConfig for controlling outbound connections:
use HttpClientConfig;
use CloudflareProvider;
// Bind to a specific source IP address
let config = new
.local_address
.timeout;
let provider = with_config?;
Available options:
local_address(IpAddr)- Bind outgoing connections to a specific local IPinterface(&str)- Bind to a network interface (Linux/macOS only, e.g.,"eth0")timeout(Duration)- Set request timeout
TLS Backend
Provider implementations use reqwest for HTTP. By default, default-tls is enabled. Alternative backends:
# Use rustls instead of native TLS
= { = "1.0", = false, = ["rustls-tls", "cloudflare"] }
Available: default-tls (default), rustls-tls, native-tls, native-tls-vendored
Comparison with Go libdns
This library adapts the Go libdns API for Rust:
| Go libdns | Rust manydns |
|---|---|
provider.GetRecords(ctx, zone) |
provider.get_zone(zone).await?.list_records().await? |
| Zone as string parameter | Zone as trait object |
Batch operations on []Record |
Single record operations |
| Delete by record content match | Delete by provider-specific ID |
Record naming conventions (@ for apex, relative names) are intentionally identical.
Contributing
Contributions welcome! See the existing provider implementations for patterns to follow when adding new providers.
License
0BSD