Documentation ¶
Index ¶
- func NewStaticProvider(servers []string) (*staticProvider, error)
- func ParseTarget(target, defaultPort string) (host, port string, err error)
- func StartDynamicProvider(c *cmd.DNSProvider, refresh time.Duration, proto string) (*dynamicProvider, error)
- type Client
- type Error
- type MockClient
- func (mock *MockClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, string, ResolverAddrs, error)
- func (mock *MockClient) LookupHost(_ context.Context, hostname string) ([]net.IP, ResolverAddrs, error)
- func (mock *MockClient) LookupTXT(_ context.Context, hostname string) ([]string, ResolverAddrs, error)
- type ResolverAddrs
- type ServerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStaticProvider ¶
func ParseTarget ¶
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:
- target: "www.google.com" defaultPort: "443" returns host: "www.google.com", port: "443"
- target: "ipv4-host:80" defaultPort: "443" returns host: "ipv4-host", port: "80"
- target: "[ipv6-host]" defaultPort: "443" returns host: "ipv6-host", port: "443"
- target: ":80" defaultPort: "443" returns host: "localhost", port: "80"
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 ¶
func StartDynamicProvider(c *cmd.DNSProvider, refresh time.Duration, proto string) (*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.
`proto` is the IP protocol (tcp or udp) to look up SRV records for.
Types ¶
type Client ¶
type Client interface { LookupTXT(context.Context, string) (txts []string, resolver ResolverAddrs, err error) LookupHost(context.Context, string) ([]net.IP, ResolverAddrs, error) LookupCAA(context.Context, string) ([]*dns.CAA, string, ResolverAddrs, 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, tlsConfig *tls.Config, ) Client
New constructs a new DNS resolver object that utilizes the provided list of DNS servers for resolution.
`tlsConfig` is the configuration used for outbound DoH queries, if applicable.
func NewTest ¶
func NewTest( readTimeout time.Duration, servers ServerProvider, stats prometheus.Registerer, clk clock.Clock, maxTries int, log blog.Logger, tlsConfig *tls.Config, ) 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
type MockClient ¶
MockClient is a mock
func (*MockClient) LookupCAA ¶
func (mock *MockClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, string, ResolverAddrs, error)
LookupCAA returns mock records for use in tests.
func (*MockClient) LookupHost ¶
func (mock *MockClient) LookupHost(_ context.Context, hostname string) ([]net.IP, ResolverAddrs, error)
LookupHost is a mock
func (*MockClient) LookupTXT ¶
func (mock *MockClient) LookupTXT(_ context.Context, hostname string) ([]string, ResolverAddrs, error)
LookupTXT is a mock
type ResolverAddrs ¶
type ResolverAddrs []string
ResolverAddrs contains DNS resolver(s) that were chosen to perform a validation request or CAA recheck. A ResolverAddr will be in the form of host:port, A:host:port, or AAAA:host:port depending on which type of lookup was done.
type ServerProvider ¶
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).