sysresolv

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Unlicense Imports: 11 Imported by: 1

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 added in v0.17.0

type SystemResolvers struct {
	// contains filtered or unexported fields
}

SystemResolvers used to discover the default DNS resolvers used by the operating system.

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 added in v0.17.0

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 added in v0.17.0

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