he

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 16 Imported by: 4

README

Hurricane Electric for libdns

Go Reference

This package implements the libdns interfaces for Hurricane Electric, allowing you to manage DNS records.

This package uses the dynamic DNS feature of Hurricane Electric Hosted DNS.

Configuration

To configure a dynamic DNS record in HE, login to the HE DNS portal and select the domain to configure the record under.

Add a new A/AAAA/TXT record and select the "Enable entry for dynamic dns" option.

Once the record has been created click the Generate a DDNS key 🗘 button and set a key.

Example

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/libdns/he"
	"github.com/libdns/libdns"
)

func main() {
	key := os.Getenv("LIBDNS_HE_KEY")
	if key == "" {
		fmt.Println("LIBDNS_HE_KEY not set")
		return
	}

	zone := os.Getenv("LIBDNS_HE_ZONE")
	if zone == "" {
		fmt.Println("LIBDNS_HE_ZONE not set")
		return
	}

	p := &he.Provider{
		APIKey: key,
	}

	records := []libdns.Record{
		{
			Type:  "A",
			Name:  "test",
			Value: "198.51.100.1",
		},
		{
			Type:  "AAAA",
			Name:  "test",
			Value: "2001:0db8::1",
		},
		{
			Type:  "TXT",
			Name:  "test",
			Value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
		},
	}

	ctx := context.Background()
	_, err := p.SetRecords(ctx, zone, records)
	if err != nil {
		fmt.Printf("Error: %v", err)
		return
	}
}

Documentation

Overview

Package libdnshe implements a DNS record management client compatible with the libdns interfaces for Hurricane Electric.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// Hurricane Electric DDNS key to use for authentication when modifying DNS records.
	APIKey string `json:"api_key,omitempty"`
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with Hurricane Electric.

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. NOTE: This implementation is NOT atomic.

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. NOTE: This implementation is NOT atomic.

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. NOTE: This implementation is NOT atomic.

Jump to

Keyboard shortcuts

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