updater

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package updater pushes IP address updates to dynamic DNS services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIP

func AddIP(a net.IP, b net.IP) net.IP

AddIP adds together the hexadecimal contents of the provided IP addresses.

func MaskIP

func MaskIP(ip net.IP, mask int) net.IP

MaskIP zeroes out the specified number of lower bits in the provided IP address.

func RecordTypeString

func RecordTypeString(rtype RecordType) string

RecordTypeString returns the string equivalent to a RecordType value.

func SlaacBits

func SlaacBits(mac net.HardwareAddr) net.IP

SlaacBits returns an IPv6 address with the lower 64 bits derived from the provided MAC address using the EUI-64 derivation.

Types

type CloudflareService

type CloudflareService struct {
	// contains filtered or unexported fields
}

CloudflareService implements the Cloudflare DNS protocol.

func (*CloudflareService) Identifier

func (s *CloudflareService) Identifier() string

Identifier returns a human readable name for this service given its endpoint.

func (*CloudflareService) Submit

func (s *CloudflareService) Submit(ctx context.Context, rtype RecordType, ip net.IP) (retryAfter time.Duration, err error)

Submit sends the provided IP address to the dynamic DNS service. In case of failure, it returns a retry delay and the error.

func (*CloudflareService) SupportsRecord

func (s *CloudflareService) SupportsRecord(rtype RecordType) bool

SupportsRecord determines whether this service supports the provided DNS record type.

func (*CloudflareService) UnmarshalYAML

func (s *CloudflareService) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML constructs a service from a YAML configuration.

type DuckService

type DuckService struct {
	// contains filtered or unexported fields
}

DuckService implements the Duck DNS protocol.

func (*DuckService) Identifier

func (s *DuckService) Identifier() string

Identifier returns a human readable name for this service given its endpoint.

func (*DuckService) Submit

func (s *DuckService) Submit(ctx context.Context, rtype RecordType, ip net.IP) (retryAfter time.Duration, err error)

Submit sends the provided IP address to the dynamic DNS service. In case of failure, it returns a retry delay and the error.

func (*DuckService) SupportsRecord

func (s *DuckService) SupportsRecord(rtype RecordType) bool

SupportsRecord determines whether this service supports the provided DNS record type.

func (*DuckService) UnmarshalYAML

func (s *DuckService) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML constructs a service from a YAML configuration.

type IPLookup

type IPLookup struct {
	// contains filtered or unexported fields
}

IPLookup uses an Internet service to look up the machine's source IP address.

func NewIPLookup

func NewIPLookup() IPLookup

NewIPLookup initializes a new IPLookup.

func (IPLookup) WebFacingIP

func (l IPLookup) WebFacingIP(ctx context.Context, rtype RecordType, intname string) net.IP

WebFacingIP looks up the machine's source IP address from the provided network interface.

type NoIPService added in v1.1.0

type NoIPService struct {
	DefinedEndpoint string
	// contains filtered or unexported fields
}

NoIPService implements the No-IP protocol. It requires an endpoint.

func (*NoIPService) Identifier added in v1.1.0

func (s *NoIPService) Identifier() string

Identifier returns a human readable name for this service given its endpoint.

func (*NoIPService) Submit added in v1.1.0

func (s *NoIPService) Submit(ctx context.Context, rtype RecordType, ip net.IP) (retryAfter time.Duration, err error)

Submit sends the provided IP address to the dynamic DNS service. In case of failure, it returns a retry delay and the error.

func (*NoIPService) SupportsRecord added in v1.1.0

func (s *NoIPService) SupportsRecord(rtype RecordType) bool

SupportsRecord determines whether this service supports the provided DNS record type.

func (*NoIPService) UnmarshalYAML added in v1.1.0

func (s *NoIPService) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML constructs a service from a YAML configuration.

type RecordService

type RecordService interface {
	// Submit a new record value.
	Submit(context.Context, RecordType, net.IP) (retryAfter time.Duration, err error)

	// Retrieve a human-readable name for this record.
	Identifier() string

	// Determine support for a record type.
	SupportsRecord(RecordType) bool

	yaml.Unmarshaler
}

A RecordService manages transactions concerning a particular record with a dynamic DNS service.

type RecordType

type RecordType int

RecordType represents a kind of dynamic DNS record.

const (
	// ARecord represents an IPv4 DNS record.
	ARecord RecordType = iota

	// AAAARecord represents an IPv6 DNS record.
	AAAARecord
)

type Updater

type Updater struct {
	Type       RecordType
	Interface  string
	Service    RecordService
	IPOffset   net.IP
	IPMaskBits int

	yaml.Unmarshaler
	// contains filtered or unexported fields
}

An Updater manages a single DNS record.

func (*Updater) DryRun

func (u *Updater) DryRun(ctx context.Context, logger *log.Logger)

DryRun performs an IP address lookup, but does not refresh the record.

func (*Updater) UnmarshalYAML

func (u *Updater) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML constructs an updater from a YAML configuration.

func (*Updater) Update

func (u *Updater) Update(ctx context.Context, logger *log.Logger)

Update attempts to refresh the record if necessary. It should be called every few minutes.

type Updaters

type Updaters []*Updater

Updaters represents a slice of updaters defined by a YAML configuration. All updaters share the same IP address lookup cache.

func (*Updaters) DryRun

func (u *Updaters) DryRun(ctx context.Context, logger *log.Logger)

DryRun tests all of the updaters in this slice.

func (*Updaters) UnmarshalYAML

func (u *Updaters) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML constructs a slice of updaters from a YAML configuration.

func (*Updaters) Update

func (u *Updaters) Update(ctx context.Context, logger *log.Logger)

Update processes all of the updaters in this slice.

Jump to

Keyboard shortcuts

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