Documentation ¶
Overview ¶
Package sysresolv provides cross-platform functionality to discover DNS resolvers currently used by the system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostGenFunc ¶
type HostGenFunc func() (hostname string)
HostGenFunc is a function used for generating hostnames to check the system DNS. The generated hosts should be unique to avoid resolver's cache. Implementations must be safe for concurrent use.
type SystemResolvers ¶
type SystemResolvers struct {
// contains filtered or unexported fields
}
SystemResolvers is a default implementation of the Resolvers interface.
func NewSystemResolvers ¶
func NewSystemResolvers(genHost HostGenFunc, defaultPort uint16) (sr *SystemResolvers, err error)
NewSystemResolvers returns a SystemResolvers instance that uses genHost to generate fake hosts for dialing, see HostGenFunc. The default generator is used, if genHost is nil. The defaultPort is used when resolvers are provided without a port number.
func (*SystemResolvers) Addrs ¶
func (sr *SystemResolvers) Addrs() (addrs []netip.AddrPort)
Addrs returns all the collected resolvers' addresses. Caller must clone the returned slice before modifying it. It is safe for concurrent use.
func (*SystemResolvers) Refresh ¶
func (sr *SystemResolvers) Refresh() (err error)
Refresh updates the internal cache of the resolvers' addresses if no error occurred. It is safe for concurrent use.