dnsservice

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImmutableRecord = errors.New("attempted to modify an immutable record")
	ErrNotAuthorized   = errors.New("not authorized to perform this action")
	ErrRecordCreation  = errors.New("failed to create record")
	ErrRecordDeletion  = errors.New("failed to delete record")
)
View Source
var ErrServerNotReachable = errors.New("server not reachable")

Functions

This section is empty.

Types

type Client

type Client struct {
	SyncInterval        int
	HealthCheckInterval int
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config DNSConfig) (*Client, error)

func (*Client) AddRecord

func (c *Client) AddRecord(record Record) error

func (*Client) Close

func (c *Client) Close()

func (*Client) GetIPv4

func (c *Client) GetIPv4() string

func (*Client) GetIPv6

func (c *Client) GetIPv6() string

func (*Client) GetRecordByFQDNAndType

func (c *Client) GetRecordByFQDNAndType(recordFQDN, recordType string) *Record

func (*Client) GetRecordByHash

func (c *Client) GetRecordByHash(targetHash string) *Record

func (*Client) GetRecordForFQDN

func (c *Client) GetRecordForFQDN(targetFQDN, recordType string) *Record

func (*Client) GetRecords

func (c *Client) GetRecords() []Record

func (*Client) GetZone

func (c *Client) GetZone() string

func (*Client) HealthCheck

func (c *Client) HealthCheck() HealthState

func (*Client) RemoveRecord

func (c *Client) RemoveRecord(record Record) error

type ClientConfig

type ClientConfig struct {
	SyncInterval        int
	HealthCheckInterval int
	Ipv4                string
	Ipv6                string
	Guards              RecordGuards
}

type DNSConfig

type DNSConfig struct {
	ServerConfig `mapstructure:"server"`
	ClientConfig `mapstructure:"client"`
}

type GuardMap

type GuardMap struct {
	Immutable map[RecordGuard]bool
	AdminOnly map[RecordGuard]bool
}

type HealthState

type HealthState struct {
	ServerReachable bool
	LastChecked     time.Time
	LastSynced      time.Time
	SyncError       error
	CheckError      error
}

type MockClient

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

func NewMockClient

func NewMockClient() *MockClient

func NewMockClientWithTestRecords

func NewMockClientWithTestRecords() *MockClient

func (*MockClient) AddRecord

func (m *MockClient) AddRecord(record Record) error

func (*MockClient) Close

func (m *MockClient) Close()

func (*MockClient) GetIPv4

func (m *MockClient) GetIPv4() string

func (*MockClient) GetIPv6

func (m *MockClient) GetIPv6() string

func (*MockClient) GetRecordByFQDNAndType

func (m *MockClient) GetRecordByFQDNAndType(recordFQDN, recordType string) *Record

func (*MockClient) GetRecordByHash

func (m *MockClient) GetRecordByHash(targetHash string) *Record

func (*MockClient) GetRecordForFQDN

func (m *MockClient) GetRecordForFQDN(targetFQDN, recordType string) *Record

func (*MockClient) GetRecords

func (m *MockClient) GetRecords() []Record

func (*MockClient) GetZone

func (m *MockClient) GetZone() string

func (*MockClient) HealthCheck

func (m *MockClient) HealthCheck() HealthState

func (*MockClient) RemoveRecord

func (m *MockClient) RemoveRecord(record Record) error

type Record

type Record struct {
	Type string
	FQDN string
	IP   string
	TTL  uint
	Hash string
}

func NewRecord

func NewRecord(typ, fqdn, ip string, ttl uint) Record

func NewRecordFromHost

func NewRecordFromHost(typ, hostname, ip string, ttl uint, zone, ipv4, ipv6 string) Record

func (Record) String

func (r Record) String() string

type RecordGuard

type RecordGuard struct {
	Type string
	FQDN string
}

func NewRecordGuard

func NewRecordGuard(t, fqdn string) RecordGuard

type RecordGuards

type RecordGuards struct {
	Immutable     []string `mapstructure:"immutable"`
	AdminEditable []string `mapstructure:"admin_only"`
}

type ServerConfig

type ServerConfig struct {
	Addr       string
	Zone       string
	TsigKey    string
	TsigSecret string
}

type Service

type Service interface {
	HealthCheck() HealthState
	GetRecords() []Record
	AddRecord(Record) error
	RemoveRecord(Record) error
	GetRecordByHash(string) *Record
	GetRecordForFQDN(string, string) *Record
	GetRecordByFQDNAndType(string, string) *Record
	GetZone() string
	GetIPv4() string
	GetIPv6() string
	Close()
}

Jump to

Keyboard shortcuts

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