func NewStaticProvider(servers []string) (*staticProvider, error)
func ParseTarget(target, defaultPort string) (host, port string, err error)
ParseTarget takes the user input target string and default port, returns formatted host and port info. If target doesn't specify a port, set the port to be the defaultPort. If target is in IPv6 format and host-name is enclosed in square brackets, brackets are stripped when setting the host.
Examples:
This function is copied from: https://github.com/grpc/grpc-go/blob/master/internal/resolver/dns/dns_resolver.go It has been minimally modified to fit our code style.
func StartDynamicProvider(c *cmd.DNSProvider, 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.
Client queries for DNS records
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) }
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( 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).
Error wraps a DNS error with various relevant information
type Error struct {
// contains filtered or unexported fields
}
func (d Error) Error() string
MockClient is a mock
type MockClient struct { Log blog.Logger }
func (mock *MockClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, string, error)
LookupCAA returns mock records for use in tests.
func (mock *MockClient) LookupHost(_ context.Context, hostname string) ([]net.IP, error)
LookupHost is a mock
func (mock *MockClient) LookupTXT(_ context.Context, hostname string) ([]string, error)
LookupTXT is a mock
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).
type ServerProvider interface { Addrs() ([]string, error) Stop() }