sysresolv

package
v0.0.0-...-9d39026 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Unlicense Imports: 12 Imported by: 0

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.

Jump to

Keyboard shortcuts

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