Documentation
¶
Overview ¶
Package dnsprovider abstracts DNS record management across providers.
Cloudflare is implemented today; the Provider interface and the registry keep room for Aliyun / DNSPod / Route53 without touching callers. Each record carries a Comment field — that is where a record's "note" lives, mapping onto Cloudflare's native per-record comment.
Index ¶
- func MarshalCreds(v any) ([]byte, error)
- func Names() []string
- func Register(name string, f Factory)
- type Cloudflare
- func (c *Cloudflare) CreateRecord(ctx context.Context, zoneID string, r Record) (Record, error)
- func (c *Cloudflare) DeleteRecord(ctx context.Context, zoneID, recordID string) error
- func (c *Cloudflare) ListRecords(ctx context.Context, zoneID string) ([]Record, error)
- func (c *Cloudflare) ListZones(ctx context.Context) ([]Zone, error)
- func (c *Cloudflare) UpdateRecord(ctx context.Context, zoneID string, r Record) (Record, error)
- func (c *Cloudflare) VerifyZone(ctx context.Context, zoneID string) (string, error)
- type DNSPod
- func (d *DNSPod) CreateRecord(ctx context.Context, zoneID string, r Record) (Record, error)
- func (d *DNSPod) DeleteRecord(ctx context.Context, zoneID, recordID string) error
- func (d *DNSPod) ListRecords(ctx context.Context, zoneID string) ([]Record, error)
- func (d *DNSPod) ListZones(ctx context.Context) ([]Zone, error)
- func (d *DNSPod) UpdateRecord(ctx context.Context, zoneID string, r Record) (Record, error)
- func (d *DNSPod) VerifyZone(ctx context.Context, zoneID string) (string, error)
- type Factory
- type Provider
- type Record
- type Zone
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalCreds ¶
MarshalCreds is a small helper for callers building credential blobs.
Types ¶
type Cloudflare ¶
type Cloudflare struct {
// contains filtered or unexported fields
}
Cloudflare implements Provider against the Cloudflare API v4.
func (*Cloudflare) CreateRecord ¶
func (*Cloudflare) DeleteRecord ¶
func (c *Cloudflare) DeleteRecord(ctx context.Context, zoneID, recordID string) error
func (*Cloudflare) ListRecords ¶
func (*Cloudflare) UpdateRecord ¶
func (*Cloudflare) VerifyZone ¶
type DNSPod ¶
type DNSPod struct {
// contains filtered or unexported fields
}
DNSPod implements Provider against the legacy DNSPod login-token API (https://dnsapi.cn). Zones are identified by their DNSPod numeric domain_id, which callers store as the domain's ZoneID.
func (*DNSPod) CreateRecord ¶
func (*DNSPod) DeleteRecord ¶
func (*DNSPod) ListRecords ¶
func (*DNSPod) UpdateRecord ¶
type Provider ¶
type Provider interface {
// ListZones returns every zone (domain) the credentials can manage.
ListZones(ctx context.Context) ([]Zone, error)
ListRecords(ctx context.Context, zoneID string) ([]Record, error)
CreateRecord(ctx context.Context, zoneID string, r Record) (Record, error)
UpdateRecord(ctx context.Context, zoneID string, r Record) (Record, error)
DeleteRecord(ctx context.Context, zoneID, recordID string) error
// VerifyZone confirms the credentials can access the zone and returns its name.
VerifyZone(ctx context.Context, zoneID string) (string, error)
}
Provider is the DNS backend contract.
type Record ¶
type Record struct {
ID string `json:"id"`
Type string `json:"type"` // A, AAAA, CNAME, TXT, MX, ...
Name string `json:"name"`
Content string `json:"content"`
TTL int `json:"ttl"`
Proxied bool `json:"proxied"`
Comment string `json:"comment"` // the per-record note
Priority *int `json:"priority,omitempty"`
}
Record is a provider-agnostic DNS record.