connbyte

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 11 Imported by: 0

README

ConnByte for libdns

Go Reference

This package implements the libdns interfaces for ConnByte, allowing you to manage DNS records with the ConnByte DNS API.

Authenticating

Create an API token in your ConnByte account. The token needs access to the DNS zones you want to manage.

Example

package main

import (
	"context"
	"fmt"
	"os"
	"time"

	"github.com/libdns/connbyte"
	"github.com/libdns/libdns"
)

func main() {
	provider := &connbyte.Provider{APIToken: os.Getenv("CONNBYTE_TOKEN")}

	recs, err := provider.AppendRecords(context.Background(), "example.com.", []libdns.Record{
		libdns.TXT{Name: "_acme-challenge", Text: "token", TTL: 2 * time.Minute},
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(recs)
}

Notes

  • Supported record types: A, AAAA, CNAME, MX, NS, SRV, TXT.
  • TTLs are clamped to the API range of 60 to 86400 seconds. A TTL of 0 means 3600 seconds.
  • The API has no batch operations. SetRecords and DeleteRecords are not atomic.
  • ListZones is supported.

Documentation

Overview

Package connbyte implements a DNS record management client compatible with the libdns interfaces for ConnByte (https://connbyte.com/).

It uses the ConnByte DNS API (https://api.connbyte.com/) with a bearer token.

Supported record types are the ones accepted by the ConnByte API: A, AAAA, CNAME, MX, NS, SRV and TXT.

The ConnByte API has no batch operations, so SetRecords and DeleteRecords are not atomic. If an error occurs part way, some changes may already be applied.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status apiStatus
	Field  []map[string]string
}

APIError is returned when the ConnByte API answers with a non-2xx status.

func (*APIError) Error

func (e *APIError) Error() string

type Provider

type Provider struct {
	// APIToken is the ConnByte API token (required).
	APIToken string `json:"api_token,omitempty"`

	// BaseURL overrides the API endpoint. Optional, defaults to https://api.connbyte.com.
	BaseURL string `json:"base_url,omitempty"`

	// HTTPClient is used for API calls. Optional.
	HTTPClient *http.Client `json:"-"`
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with ConnByte.

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 specified records from the zone. It returns the records that were deleted. Type, TTL and value may be left empty to match any value. Records that do not exist are ignored.

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 returns the zones of the account.

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. For every (name, type) pair in the input, existing records that are not in the input are deleted. It returns the records that were set (kept or created). This operation is not atomic.

Jump to

Keyboard shortcuts

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