Documentation
¶
Overview ¶
Package servercow implements a libdns provider for the Servercow DNS API.
The Servercow DNS API is documented at: https://wiki.servercow.de/en/domains/dns_api/api-syntax/
Authentication uses a username and password created in the Servercow customer portal under "DNS API".
Supported record types are A, AAAA, CNAME, TXT, MX, CAA, TLSA, SRV, SSHFP, SMIMEA, HTTPS and SVCB.
The API stores multiple content values under one (name, type) key only for TXT, CAA, TLSA, HTTPS and SVCB. For all other types, including SRV, SSHFP and SMIMEA, only a single value is stored per (name, type) pair; SetRecords and AppendRecords return an error if more than one value is supplied for such a pair.
Note on AppendRecords: For multi-value record types (TXT, CAA, TLSA, HTTPS, SVCB), this method performs a read-modify-write to preserve existing values. For single-value types it behaves identically to SetRecords because the Servercow API stores only one value set per (name, type) pair and does not distinguish between create and update.
Servercow's current API restricts the owner names and content it accepts for some types: owner names containing "_" are rejected for SRV, SSHFP, SMIMEA and CAA, and SRV content is only accepted with the target "." (a real target name is rejected). Conventional SRV records such as _sip._tcp therefore cannot currently be created through the API.
Index ¶
- type Provider
- func (p *Provider) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) DeleteRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)
- func (p *Provider) SetRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// Username is the Servercow DNS API username.
Username string `json:"username"`
// Password is the Servercow DNS API password.
Password string `json:"password"`
// contains filtered or unexported fields
}
Provider implements the libdns DNS provider interfaces for Servercow.
func (*Provider) AppendRecords ¶
func (p *Provider) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)
AppendRecords adds records to the zone. For multi-value types (TXT, CAA, TLSA, HTTPS, SVCB) it reads existing values first and merges the new ones to avoid overwriting. For single-value types it behaves like SetRecords.
When merging into an existing multi-value record, the TTL of the existing record is preserved (the caller-supplied TTL is ignored). This is intentional: the Servercow API stores one TTL per (name, type) pair, and changing it while appending a value would be a surprising side effect.
func (*Provider) DeleteRecords ¶
func (p *Provider) DeleteRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)
DeleteRecords removes records from the zone. For multi-value types (TXT, CAA, TLSA, SVCB, HTTPS) it reads existing values once and removes only the matching ones; if all values are removed it issues a full DELETE. For single-value types it issues a DELETE directly.
func (*Provider) GetRecords ¶
GetRecords returns all DNS records for the given zone. zone must be a fully-qualified domain name with a trailing dot (e.g. "example.com.").
func (*Provider) SetRecords ¶
func (p *Provider) SetRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)
SetRecords sets records in the zone, creating or replacing as needed. For a given (name, type) pair, any previous content is fully replaced.
Only multi-value types may carry more than one value for the same (name, type) pair. For single-value types the Servercow API stores a single content value, so SetRecords returns an error if multiple values are supplied for one pair instead of letting the API fail with an opaque HTTP 500 response.