NodeRings for libdns
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.
| 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.
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)
}- Record sets. NodeRings stores all records with the same name and type as one record set with one TTL.
AppendRecordsadds to an existing set and keeps its TTL.SetRecordsrejects input that gives one set two different TTLs. - Concurrency. Changes go through read-modify-write of the record set. Calls on one
Providerare serialized, so concurrent appends to the same name (for example the two TXT values of a wildcard certificate) both land. SeparateProvidervalues 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.
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).