netnod

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Netnod DNS for libdns

godoc reference

This package implements the libdns interfaces for the Netnod Primary DNS API.

Netnod DNS services

Authenticating

To authenticate, you need a Netnod API token. Generate one through the Netnod customer portal and ensure your client IP is within the configured prefix range.

Example

provider := &netnod.Provider{
    APIToken: "your-api-token",
}

records, err := provider.GetRecords(context.Background(), "example.com.")

See provider_test.go for more usage examples.

Caveats

Rate Limiting

The Netnod API enforces rate limiting (HTTP 429). This provider automatically retries rate-limited requests using exponential backoff, respecting the Retry-After header when present. It is important to set a deadline on the context to avoid retrying indefinitely:

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
records, err := provider.GetRecords(ctx, "example.com.")
TTL

The Netnod API operates on RRsets (all records sharing a name and type). A single TTL applies to the entire RRset. If multiple records with the same name and type specify different TTLs, only the first value is used.

Atomicity

Updates are not atomic across processes. Concurrent modifications from multiple processes to the same RRset may result in inconsistent state. To avoid conflicts, ensure that concurrent processes operate on different RRsets.

Testing

Run integration tests against a live Netnod account:

NETNOD_API_TOKEN=your-token NETNOD_TEST_ZONE=example.com. go test -race -v ./...

License

BSD 3-Clause

Documentation

Overview

Package netnod implements a DNS record management client compatible with the libdns interfaces for the Netnod Primary DNS API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// APIToken is the authentication token for the Netnod API.
	APIToken string `json:"api_token,omitempty"`

	// BaseURL optionally overrides the default API base URL.
	// Useful for testing.
	BaseURL string `json:"base_url,omitempty"`

	// HTTPClient optionally overrides the default HTTP client.
	HTTPClient *http.Client `json:"-"`
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with the Netnod Primary DNS API.

func (*Provider) AppendRecords

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

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

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

DeleteRecords deletes the records from the zone. It returns the records that were deleted.

func (*Provider) GetRecords

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

GetRecords lists all the records in the zone.

func (*Provider) ListZones

func (p *Provider) ListZones(ctx context.Context) ([]libdns.Zone, error)

ListZones lists the zones available in the account.

func (*Provider) SetRecords

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

SetRecords sets the records in the zone, fully replacing any existing records with the same name and type. It returns the records that were set.

Jump to

Keyboard shortcuts

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