autodns

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 10 Imported by: 6 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

<autodns> for libdns

Go Reference

This package implements the libdns interfaces for <autodns>, allowing you to manage DNS records.

Example:

package main

import (
	"context"
	"fmt"
	"os"
	"log"

	"github.com/libdns/autodns"
)

func main() {
	provider := autodns.NewWithDefaults(os.Getenv("AUTODNS_USERNAME"), os.Getenv("AUTODNS_PASSWORD"))

	records, err := provider.GetRecords(context.TODO(), "zone.example.org")
	if err != nil {
		log.Fatalf("unexpected error: %s", err)
	}

	fmt.Printf("%#v", records)
}

Customize

To customize the connection further (e.g. when using a sub account of another account), configure the SDK struct with the following:

Field Description (default) Required
Username username, empty yes
Password password, empty yes
Endpoint https://api.autodns.com/v1 no
Context 4 no
HttpClient &http.Client{} no
package main

import (
	"context"
	"os"
	"log"

	"github.com/libdns/autodns"
	"github.com/libdns/autodns/sdk"
)

func main() {
	provider := autodns.NewWithSDK(&sdk.SDK{
		Username: os.Getenv("AUTODNS_USERNAME"),
		Password: os.Getenv("AUTODNS_PASSWORD"),
		Context:  "123",
	})

	// use the provider
}

Shortcut

By default, the library will try to resolve the zone name and the primary nameserver which are needed for requests against the API. When working with a single zone, you can configure these yourself and skip the extra requests:

var(
	zone = "example.org"
	nameServer = "ns1.autodns.eu"
)

provider := autodns.NewWithDefaults(os.Getenv("AUTODNS_USERNAME"), os.Getenv("AUTODNS_PASSWORD"))
provider.Zone = &zone
provider.Nameserver = &nameServer

Documentation

Overview

Helper functions for record conversion

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasRecord

func HasRecord(name, rrType string, records []libdns.Record) bool

func HasWWWInclude

func HasWWWInclude(zone sdk.ZoneItem) bool

func MatchesZoneRecord

func MatchesZoneRecord(target, zr sdk.ZoneRecord) bool

MatchesZoneRecord reports whether zr matches target using libdns's wildcard rules: Name must match exactly; empty Type/TTL/Value in target act as wildcards.

func ToAutoDNS

func ToAutoDNS(record libdns.Record) (sdk.ZoneRecord, error)

ToAutoDNS converts a libdns Record to an AutoDNS ZoneRecord

func ToLibDNS

func ToLibDNS(zr sdk.ZoneRecord) (libdns.Record, error)

ToLibDNS converts an AutoDNS ZoneRecord to a libdns Record

Types

type Provider

type Provider struct {
	Client *sdk.SDK

	// Optional fields to skip zone lookup if already known
	Zone       *string `json:"origin,omitempty"`
	Nameserver *string `json:"nameserver,omitempty"`
}

Provider facilitates DNS record manipulation with AutoDNS.

func NewWithDefaults

func NewWithDefaults(username, password string) *Provider

NewWithDefaults is a convenience method to create the provider with sensible defaults.

func NewWithSDK

func NewWithSDK(client *sdk.SDK) *Provider

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []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, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. It returns the records that were deleted. Per the libdns contract, records that don't exist are silently ignored, matching is exact on Name+Type+TTL+Value, and empty Type/TTL/Value act as wildcards.

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) SetRecords

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

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

Directories

Path Synopsis
Package sdk is a thin HTTP client for the AutoDNS (Domainrobot) JSON API.
Package sdk is a thin HTTP client for the AutoDNS (Domainrobot) JSON API.

Jump to

Keyboard shortcuts

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