Skip to content
libdnsPublic

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

NodeRings for libdns

Go Reference

This package implements the libdns interfaces for NodeRings DNS, allowing you to manage DNS records. NodeRings serves zones from anycast nameservers (ans1.nrings.io, ans2.nrings.io).

It implements RecordGetter, RecordAppender, RecordSetter, RecordDeleter and ZoneLister.

Configuration

Field JSON Environment default Description
APIToken api_token NODERINGS_API_TOKEN Required. A NodeRings user API token or service account token with access to the zone.
OrganizationID organization_id NODERINGS_ORGANIZATION_ID Only needed when the token belongs to more than one organization.
BaseURL base_url NODERINGS_API_URL API base URL. Default https://api.noderings.com.
HTTPClient – – Optional *http.Client. Default: 30 s timeout.

Environment variables are used only when the field is empty.

Example

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/libdns/libdns"
	"github.com/libdns/noderings"
)

func main() {
	p := &noderings.Provider{APIToken: "YOUR_TOKEN"}
	ctx := context.Background()

	_, err := p.AppendRecords(ctx, "example.com.", []libdns.Record{
		libdns.TXT{Name: "_acme-challenge", TTL: 60 * time.Second, Text: "token"},
	})
	if err != nil {
		panic(err)
	}

	recs, err := p.GetRecords(ctx, "example.com.")
	if err != nil {
		panic(err)
	}
	fmt.Println(recs)
}

Caveats

  • Record sets. NodeRings stores all records with the same name and type as one record set with one TTL. AppendRecords adds to an existing set and keeps its TTL. SetRecords rejects input that gives one set two different TTLs.
  • Concurrency. Changes go through read-modify-write of the record set. Calls on one Provider are serialized, so concurrent appends to the same name (for example the two TXT values of a wildcard certificate) both land. Separate Provider values or processes changing the same record set at the same moment can still race.
  • Atomicity. Changes are not atomic across record sets: if a call fails part-way, sets written before the failure keep their new contents.
  • TTL. NodeRings accepts TTLs from 30 seconds to one day. Shorter TTLs (including 0, "do not cache") are stored as 30 seconds, longer ones as 86400 seconds.
  • TXT values. Values longer than 255 bytes are split into several character-strings and joined again when read.
  • DNSSEC. DNSSEC records are managed by NodeRings and are not returned by the API.
  • Retries. Connection errors, HTTP 429 and HTTP 5xx are retried 3 times (about 2.5 s in total), and context cancellation is honoured.

Tests

go test ./...

TestLive runs against the real API when NODERINGS_API_TOKEN and NODERINGS_TEST_ZONE (for example example.com.) are set. It creates and removes two TXT values under _libdns-test.

The provider also passes the shared libdnstest suite (all record types, run against the production API).

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from libdns/template