Documentation ¶
Index ¶
- type Resolver
- func (r *Resolver) Dial(ctx context.Context, network string, addr string) (conn net.Conn, err error)
- func (r *Resolver) LookupAddr(ctx context.Context, addr string) (names []string, err error)
- func (r *Resolver) LookupHost(ctx context.Context, host string) (addrs []string, err error)
- func (r *Resolver) Refresh(clearUnused bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct { // Timeout defines the maximum allowed time allowed for a lookup. Timeout time.Duration // Resolver is the net.Resolver used to perform actual DNS lookup. If nil, // net.DefaultResolver is used instead. Resolver *net.Resolver // contains filtered or unexported fields }
Resolver adds a DNS cache layer to Go's net.Resolver.
func (*Resolver) Dial ¶
func (r *Resolver) Dial(ctx context.Context, network string, addr string) (conn net.Conn, err error)
Dial is a function to use in DialContext for http.Transport. It looks up the host via Resolver and passes it to net.Dial.
Be warned that this is a simplistic implementation and misses a lot of features like dual stack support, correct handling of context tracing, randomization of adds etc. This implementation will also choke on "unix", "unixgram" and "unixpacket" network.
func (*Resolver) LookupAddr ¶
LookupAddr performs a reverse lookup for the given address, returning a list of names mapping to that address.
func (*Resolver) LookupHost ¶
LookupHost looks up the given host using the local resolver. It returns a slice of that host's addresses.