dns

package
v0.0.0-...-b1acabd Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResolvConfPath        = "/etc/resolv.conf"
	SystemdResolvConfPath = "/run/systemd/resolve/resolv.conf"
)

Variables

This section is empty.

Functions

func GetUpstreamDNSFromFile

func GetUpstreamDNSFromFile(ctx context.Context, filename string) (<-chan UpstreamDNS, error)

func NewDNSHandler

func NewDNSHandler(options ...DNSOption) *dnsHandler

func Same

func Same[T comparable](a, b []T) bool

Types

type ClientFactory

type ClientFactory func(net string, timeout time.Duration) DNSClient

type CoreDNSServer

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

func (*CoreDNSServer) Serve

func (s *CoreDNSServer) Serve() (func(), error)

type DNSClient

type DNSClient interface {
	ExchangeContext(ctx context.Context, m *dns.Msg, address string) (r *dns.Msg, rtt time.Duration, err error)
}

type DNSConfig

type DNSConfig struct {
	Timeout       time.Duration
	ClientFactory ClientFactory
}

type DNSFailoverForwarder

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

func (*DNSFailoverForwarder) Serve

func (d *DNSFailoverForwarder) Serve() (func(), error)

type DNSForwarder

type DNSForwarder interface {
	Serve() (stop func(), err error)
}

func NewCoreDNSServer

func NewCoreDNSServer(ctx context.Context, options ...DNSForwarderOption) (DNSForwarder, error)

func NewDNSFailoverForwarder

func NewDNSFailoverForwarder(ctx context.Context, options ...DNSForwarderOption) (DNSForwarder, error)

type DNSForwarderConfig

type DNSForwarderConfig struct {
	Address        string
	Timeout        time.Duration
	ResolvconfPath string
	Zone           string
	Upstreams      []string
	ReusePort      bool
}

type DNSForwarderOption

type DNSForwarderOption func(*DNSForwarderConfig)

func WithForwarderAddress

func WithForwarderAddress(address string) DNSForwarderOption

func WithForwarderTimeout

func WithForwarderTimeout(timeout time.Duration) DNSForwarderOption

func WithForwarderZone

func WithForwarderZone(zone string) DNSForwarderOption

func WithResolvconfPath

func WithResolvconfPath(path string) DNSForwarderOption

func WithReusePort

func WithReusePort() DNSForwarderOption

func WithUpstreams

func WithUpstreams(upstreams []string) DNSForwarderOption

type DNSOption

type DNSOption func(*DNSConfig)

func WithClientFactory

func WithClientFactory(factory ClientFactory) DNSOption

func WithTimeout

func WithTimeout(timeout time.Duration) DNSOption

type ForwarderFactory

type ForwarderFactory interface {
	NewForwarder(ctx context.Context, addr string) (DNSForwarder, error)
}

ForwarderFactory creates a DNS forwarder bound to the given address.

type InterfaceProber

type InterfaceProber interface {
	Probe() (net.IP, error)
}

InterfaceProber checks whether the target network interface is present.

type ManagedForwarder

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

ManagedForwarder tracks an interface lifecycle and starts/stops a DNS forwarder as the interface appears and disappears.

func NewManagedForwarder

func NewManagedForwarder(
	parent context.Context,
	interval time.Duration,
	prober InterfaceProber,
	factory ForwarderFactory,
) *ManagedForwarder

func (*ManagedForwarder) Serve

func (m *ManagedForwarder) Serve() (func(), error)

type UpstreamDNS

type UpstreamDNS struct {
	Endpoints []string
	Error     error
}

Jump to

Keyboard shortcuts

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