bdns

package
v0.0.0-...-30a5167 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: MPL-2.0 Imports: 16 Imported by: 136

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStaticProvider

func NewStaticProvider(servers []string) *staticProvider

func StartDynamicProvider

func StartDynamicProvider(server string, refresh time.Duration) (*dynamicProvider, error)

StartDynamicProvider constructs a new dynamicProvider and starts its auto-update goroutine. The auto-update process queries DNS for SRV records at refresh intervals and uses the resulting IP/port combos to populate the list returned by Addrs. The update process ignores the Priority and Weight attributes of the SRV records. The given server name should be a full domain name like `example.com`, which will result in SRV queries for `_dns._udp.example.com`.

Types

type Client

type Client interface {
	LookupTXT(context.Context, string) (txts []string, err error)
	LookupHost(context.Context, string) ([]net.IP, error)
	LookupCAA(context.Context, string) ([]*dns.CAA, string, error)
}

Client queries for DNS records

func New

func New(
	readTimeout time.Duration,
	servers ServerProvider,
	stats prometheus.Registerer,
	clk clock.Clock,
	maxTries int,
	log blog.Logger,
) Client

New constructs a new DNS resolver object that utilizes the provided list of DNS servers for resolution.

func NewTest

func NewTest(
	readTimeout time.Duration,
	servers ServerProvider,
	stats prometheus.Registerer,
	clk clock.Clock,
	maxTries int,
	log blog.Logger) Client

NewTest constructs a new DNS resolver object that utilizes the provided list of DNS servers for resolution and will allow loopback addresses. This constructor should *only* be called from tests (unit or integration).

type Error

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

Error wraps a DNS error with various relevant information

func (Error) Error

func (d Error) Error() string

type MockClient

type MockClient struct {
	Log blog.Logger
}

MockClient is a mock

func (*MockClient) LookupCAA

func (mock *MockClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, string, error)

LookupCAA returns mock records for use in tests.

func (*MockClient) LookupHost

func (mock *MockClient) LookupHost(_ context.Context, hostname string) ([]net.IP, error)

LookupHost is a mock

func (*MockClient) LookupTXT

func (mock *MockClient) LookupTXT(_ context.Context, hostname string) ([]string, error)

LookupTXT is a mock

type ServerProvider

type ServerProvider interface {
	Addrs() ([]string, error)
	Stop()
}

serverProvider represents a type which can provide a list of addresses for the bdns to use as DNS resolvers. Different implementations may provide different strategies for providing addresses, and may provide different kinds of addresses (e.g. host:port combos vs IP addresses).

Jump to

Keyboard shortcuts

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