dns

package
v1.3.11 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 36 Imported by: 0

README

This is a fork of https://pkg.go.dev/tailscale.com@v1.74.0/net/dns with modification to fit ctrld use case.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGetBaseConfigNotSupported = errors.New("getting OS base config is not supported")

ErrGetBaseConfigNotSupported is the error OSConfigurator.GetBaseConfig returns when the OSConfigurator doesn't support reading the underlying configuration out of the OS.

Functions

This section is empty.

Types

type HostEntry

type HostEntry struct {
	Addr  netip.Addr
	Hosts []string
}

HostEntry represents a single line in the OS's hosts file.

type OSConfig

type OSConfig struct {
	// Hosts is a map of DNS FQDNs to their IPs, which should be added to the
	// OS's hosts file. Currently, (2022-08-12) it is only populated for Windows
	// in SplitDNS mode and with Smart Name Resolution turned on.
	Hosts []*HostEntry
	// Nameservers are the IP addresses of the nameservers to use.
	Nameservers []netip.Addr
	// SearchDomains are the domain suffixes to use when expanding
	// single-label name queries. SearchDomains is additive to
	// whatever non-Tailscale search domains the OS has.
	SearchDomains []dnsname.FQDN
	// MatchDomains are the DNS suffixes for which Nameservers should
	// be used. If empty, Nameservers is installed as the "primary" resolver.
	// A non-empty MatchDomains requests a "split DNS" configuration
	// from the OS, which will only work with OSConfigurators that
	// report SupportsSplitDNS()=true.
	MatchDomains []dnsname.FQDN
}

OSConfig is an OS DNS configuration.

func (OSConfig) Equal

func (a OSConfig) Equal(b OSConfig) bool

func (OSConfig) Format

func (a OSConfig) Format(f fmt.State, verb rune)

Format implements the fmt.Formatter interface to ensure that Hosts is printed correctly (i.e. not as a bunch of pointers).

Fixes https://github.com/tailscale/tailscale/issues/5669

func (OSConfig) IsZero

func (o OSConfig) IsZero() bool

func (*OSConfig) WriteToBufioWriter added in v1.3.10

func (o *OSConfig) WriteToBufioWriter(w *bufio.Writer)

type OSConfigurator

type OSConfigurator interface {
	// SetDNS updates the OS's DNS configuration to match cfg.
	// If cfg is the zero value, all ctrld-related DNS
	// configuration is removed.
	// SetDNS must not be called after Close.
	// SetDNS takes ownership of cfg.
	SetDNS(cfg OSConfig) error
	// SupportsSplitDNS reports whether the configurator is capable of
	// installing a resolver only for specific DNS suffixes. If false,
	// the configurator can only set a global resolver.
	SupportsSplitDNS() bool

	// Implementations that don't support getting the base config must
	// return ErrGetBaseConfigNotSupported.
	GetBaseConfig() (OSConfig, error)
	// Close removes Tailscale-related DNS configuration from the OS.
	Close() error

	Mode() string
}

An OSConfigurator applies DNS settings to the operating system.

func NewOSConfigurator

func NewOSConfigurator(logf logger.Logf, health *health.Tracker, _ *controlknobs.Knobs, interfaceName string) (ret OSConfigurator, err error)

NewOSConfigurator created a new OS configurator.

The health tracker may be nil; the knobs may be nil and are ignored on this platform.

Directories

Path Synopsis
Package resolvconffile parses & serializes /etc/resolv.conf-style files.
Package resolvconffile parses & serializes /etc/resolv.conf-style files.

Jump to

Keyboard shortcuts

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