servercow

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 11 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

libdns/servercow

Go Reference

This package implements the libdns interfaces for Servercow, allowing DNS records to be managed via the Servercow DNS API.

Authentication

The Servercow DNS API uses username/password authentication passed in request headers. See Servercow docs for more info.

Usage

import "github.com/libdns/servercow"

provider := servercow.Provider{
    Username: "your-username",
    Password: "your-password",
}

Supported record types

A, AAAA, CNAME, TXT, MX, CAA, TLSA, SRV, SSHFP, SMIMEA, HTTPS, SVCB

Notes

  • AppendRecords for multi-value types (TXT, CAA, TLSA, HTTPS, SVCB) performs a read-modify-write to preserve existing values. For single-value types, it behaves like SetRecords because the Servercow API stores only one value set per (name, type) pair.
  • All other types, including SRV, SSHFP and SMIMEA, are single-value: the Servercow API stores only one content value per (name, type) pair. SetRecords and AppendRecords both return an error when more than one value is supplied for such a pair instead of letting the API reject the request.
  • The Servercow API currently 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.
  • Zone listing is not supported (no API endpoint).

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

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

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址