dns

package
v0.0.0-...-7f8d8f8 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package dns is for our 3rd party DNS integrations

Index

Constants

This section is empty.

Variables

View Source
var DNSOptions config.DNS

DNSOptions holds the various options from the main config we might want to use, this does mean these values are in multiple places, which is odd but they dont' change execpt on restart (today)

Functions

This section is empty.

Types

type AmazonDNS

type AmazonDNS struct {
	CredsFile string // the shared credentials filename (full path)
	Profile   string // profile within the creds file to use, "" for default
	ZoneID    string // the Route 53 DNS zone we are using
}

AmazonDNS stores all the options we need to talk to Route 53

func NewAmazonDNS

func NewAmazonDNS(credsfile string, profile string, zoneid string) *AmazonDNS

NewAmazonDNS will return our Amazon Route 53 DNS interface

func (*AmazonDNS) GetARecord

func (a *AmazonDNS) GetARecord(name string, networkBlocks []string) (string, error)

GetARecord returns an A record for our host. If the host already has one, this will return the first record encountered, it does not currently ensure that record is in the network we are asking for. If there is no existing record, it will loop over a 3 dimensional array looking for a free entry to use.

func (*AmazonDNS) ListARecords

func (a *AmazonDNS) ListARecords() ([]RecordList, error)

ListARecords repopulates the internal cache and then appends any A records it finds to a / RecordList array and returns that

func (*AmazonDNS) RemoveARecord

func (a *AmazonDNS) RemoveARecord(name string) error

RemoveARecord passes our name to deleteARecord as it doesn't have to do any additional processing

type DNS

type DNS interface {
	GetARecord(name string, networkBlocks []string) (string, error) // returns a string representation of an IPv4 address
	RemoveARecord(name string) error                                // removes the record from our 3rd party
	ListARecords() ([]RecordList, error)                            // returns a list of all the A records
}

The DNS interface provides the list of functions all our 3rd party integrations should support. I don't like that I coded the record type in the name, but until I decide I need IPv6, etc its good enough

func New

func New(conf *config.Config) DNS

New should just hand back the appropriate interface for our config settings, returning from the correct "New" function for our integration

type GoogleDNS

type GoogleDNS struct {
	Creds   []byte // the contents of our service account json credentials file
	Project string // the GCP project name we are operating on
	Zone    string // the GCP DNS zone we are using
}

GoogleDNS stores all the options we need to talk to GCP

func NewGoogleDNS

func NewGoogleDNS(creds string, project string, zone string) *GoogleDNS

NewGoogleDNS will return our GCP DNS interface The creds, project, and zone here are actually in the options as well, but they are important enough to warrant being "top level" items

func (*GoogleDNS) GetARecord

func (g *GoogleDNS) GetARecord(name string, networkBlocks []string) (string, error)

GetARecord returns an A record for our host. If the host already has one, this will return the first record encountered, it does not currently ensure that record is in the network we are asking for. If there is no existing record, it will loop over a 3 dimensional array looking for a free entry to use.

func (*GoogleDNS) ListARecords

func (g *GoogleDNS) ListARecords() ([]RecordList, error)

ListARecords repopulates the internal cache and then appends any A records it finds to a / RecordList array and returns that

func (*GoogleDNS) RemoveARecord

func (g *GoogleDNS) RemoveARecord(name string) error

RemoveARecord passes our name to deleteARecord as it doesn't have to do any additional processing

type RecordList

type RecordList struct {
	Name      string   // the name of the entry
	RecordSet []string // the values in the entry
}

RecordList is a simple look at DNS records used as a common return for our interface

Jump to

Keyboard shortcuts

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