dns

package module
v0.0.0-...-ee41f6b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 4 Imported by: 0

README

dns

dns is a go package for managing dns zones, abstracting away the individual providers. Currently only autodns is supported, but bind is planned as well for the future.

License

Licensed under MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class string

Class represents a DNS class. Most likely you want to use ClassIN.

const (
	// ClassIN represents the internet dns class
	ClassIN Class = "IN"

	// ClassCS represetns the chaos dns class
	ClassCS Class = "CS"

	// ClassHS represents the hesiod dns class.
	ClassHS Class = "HS"
)

type Provider

type Provider interface {
	// CreateZone creates the passed zone
	CreateZone(zone Zone) error

	// GetZone retrieves the zone information for the zone with the passed name.
	GetZone(name string) (Zone, error)

	// ListZones lists all zones from the provider.
	ListZones() ([]string, error)

	// UpdateZone updates the zone on the provider.
	UpdateZone(zone Zone) error

	// DeleteZone deletes the passed zone from the provider.
	DeleteZone(name string) error
}

Provider represents an abstraction over individual dns providers handling zone management

type Record

type Record struct {
	Class      Class      `yaml:"Class"`
	Name       string     `yaml:"Name"`
	TTL        int64      `yaml:"TTL"`
	Type       RecordType `yaml:"Type"`
	Value      string     `yaml:"Value"`
	Preference int64      `yaml:"Preference"`
}

Record represents a dns zone record

func NewRecord

func NewRecord(class Class, name string, ttl int64, rType RecordType, value string, preference int64) *Record

NewRecord creates a new DNS zone record

func (Record) String

func (r Record) String() string

type RecordType

type RecordType string

RecordType represents the differnet dns record types (e.g. A, MX, ...)

const (
	// RecordTypeA represents host address
	RecordTypeA RecordType = "A"

	// RecordTypeMX represents mail eXchange
	RecordTypeMX RecordType = "MX"

	// RecordTypeCNAME represents canonical name for an alias
	RecordTypeCNAME RecordType = "CNAME"

	// RecordTypeTXT represents descriptive text
	RecordTypeTXT RecordType = "TXT"

	// RecordTypeSRV represents location of service
	RecordTypeSRV RecordType = "SRV"

	// RecordTypePTR represents pointer
	RecordTypePTR RecordType = "PTR"

	// RecordTypeAAAA represents IPv6 host address
	RecordTypeAAAA RecordType = "AAAA"

	// RecordTypeNS represents the nameserver
	RecordTypeNS RecordType = "NS"

	// RecordTypeCAA represents certification authority authorization
	RecordTypeCAA RecordType = "CAA"

	// RecordTypeTLSA represents transport layer security authentication
	RecordTypeTLSA RecordType = "TLSA"

	// RecordTypeNAPTR represents naming authority pointer
	RecordTypeNAPTR RecordType = "NAPTR"

	// RecordTypeSSHFP represents secure shell fingerprint record
	RecordTypeSSHFP RecordType = "SSHFP"

	// RecordTypeLOC represents location information
	RecordTypeLOC RecordType = "LOC"

	// RecordTypeRP represents responsible person
	RecordTypeRP RecordType = "RP"

	// RecordTypeHINFO represents host information
	RecordTypeHINFO RecordType = "HINFO"

	// RecordTypeALIAS represents auto resolved alias
	RecordTypeALIAS RecordType = "ALIAS"

	// RecordTypeDNSKEY represents DNSSEC public key
	RecordTypeDNSKEY RecordType = "DNSKEY"

	// RecordTypeNSEC represents Next Secure
	RecordTypeNSEC RecordType = "NSEC"

	// RecordTypeDS represents delegation signer
	RecordTypeDS RecordType = "DS"
)

type SOA

type SOA struct {
	// MName represents the primary master name server for this zone
	MName string

	// RName represents the (encoded) email address of the administrator responsible for this zone
	RName string

	// Serial is the current serialnumber, should change with every change of the zone.
	Serial int64

	// Refresh is the number of seconds after which secondary name servers should query the master for the SOA record, to detect zone changes.
	Refresh int64

	// Retry is the number of seconds after which secondary name servers should retry to request the serial number from the master if the master does not respond.
	Retry int64

	// Expire is the number of seconds after which secondary name servers should stop answering request for this zone if the master does not respond.
	Expire int64

	// TTL is the time to live for purposes of negative caching.
	TTL int64
}

SOA represents the start of Authority record which contains administrative information about the zone

type Zone

type Zone struct {
	Name    string   `yaml:"Name"`
	Records []Record `yaml:"Records"`
	SOA     SOA      `yaml:"SOA"`
}

Zone represents a DNS Zone

func NewZone

func NewZone(name string, records []Record) *Zone

NewZone creates a new Zone using the passed parameters.

func (*Zone) Copy

func (z *Zone) Copy() Zone

Copy creates a deep-copy of the current zone structure.

func (*Zone) Equals

func (z *Zone) Equals(b *Zone) bool

Equals checks if the current zone equals the passed zone.

func (*Zone) Hash

func (z *Zone) Hash() uint64

Hash creates a hash for the current zone

func (*Zone) RemoveRecordsWithName

func (z *Zone) RemoveRecordsWithName(name string, deleteType RecordType)

RemoveRecordsWithName removes all records from the current zone which matches the passed name, and type

func (Zone) String

func (z Zone) String() string

type Zones

type Zones []*Zone

Zones represents a slice of zones

func (Zones) Copy

func (z Zones) Copy() Zones

Copy copies the current zones

func (Zones) Equals

func (z Zones) Equals(b Zones) bool

Equals checks if the current zones equals the passed zones.

func (Zones) Hash

func (z Zones) Hash() uint64

Hash creates a hash for the current zones

Directories

Path Synopsis
provider

Jump to

Keyboard shortcuts

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