Movatterモバイル変換


[0]ホーム

URL:


resolver

package
v1.92.3Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License:BSD-3-ClauseImports:49Imported by:6

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package resolver implements a stub DNS resolver that can also serverecords out of an internal local zone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcShouldUseRoutesadded inv1.84.0

func ShouldUseRoutes(knobs *controlknobs.Knobs)bool

ShouldUseRoutes reports whether the DNS resolver should consider routes when dialingupstream nameservers via TCP.

If true, routes should be considered (tsdial.Dialer.UserDial), otherwise deferto the system routes (tsdial.Dialer.SystemDial).

TODO(nickkhyl): Updatetsdial.Dialer to reuse the bart.Table we create in net/tstun.Wrapperto avoid having two bart tables in memory, especially on iOS. Once that's done,we can get rid of the nodeAttr/control knob and always use UserDial for DNS.

See tailscale/tailscale#12027.

funcWriteDNSResolveradded inv1.16.0

func WriteDNSResolver(w *bufio.Writer, r *dnstype.Resolver)

WriteDNSResolver writes r to w.

funcWriteDNSResolversadded inv1.16.0

func WriteDNSResolvers(w *bufio.Writer, resolvers []*dnstype.Resolver)

WriteDNSResolvers writes resolvers to w.

funcWriteIPPortsadded inv1.12.0

func WriteIPPorts(w *bufio.Writer, vv []netip.AddrPort)

WriteIPPorts writes vv to w.

funcWriteRoutesadded inv1.12.0

func WriteRoutes(w *bufio.Writer, routes map[dnsname.FQDN][]*dnstype.Resolver)

WriteRoutes writes routes to w, omitting *.arpa routes and insteadsummarizing how many of them there were.

Types

typeConfig

type Config struct {// Routes is a map of DNS name suffix to the resolvers to use for// queries within that suffix.// Queries only match the most specific suffix.// To register a "default route", add an entry for ".".Routes map[dnsname.FQDN][]*dnstype.Resolver// LocalHosts is a map of FQDNs to corresponding IPs.Hosts map[dnsname.FQDN][]netip.Addr// LocalDomains is a list of DNS name suffixes that should not be// routed to upstream resolvers.LocalDomains []dnsname.FQDN}

Config is a resolver configuration.Given a Config, queries are resolved in the following order:If the query is an exact match for an entry in LocalHosts, return that.Else if the query suffix matches an entry in LocalDomains, return NXDOMAIN.Else forward the query to the most specific matching entry in Routes.Else return SERVFAIL.

func (*Config)RoutesRequireNoCustomResolversadded inv1.68.0

func (c *Config) RoutesRequireNoCustomResolvers()bool

RoutesRequireNoCustomResolvers returns true if this resolver.Config only contains routesthat do not specify a set of custom resolver(s), i.e. they can be resolved by the localupstream DNS resolver.

func (*Config)WriteToBufioWriteradded inv1.12.0

func (c *Config) WriteToBufioWriter(w *bufio.Writer)

WriteToBufioWriter write a debug version of c for logs to w, omittingspammy stuff like *.arpa entries and replacing it with a total count.

typeForwardLinkSelectoradded inv1.10.0

type ForwardLinkSelector interface {// PickLink returns which network device should be used to query// the DNS server at the given IP.// The empty string means to use an unspecified default.PickLink(netip.Addr) (linkNamestring)}

typeResolver

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

Resolver is a DNS resolver for nodes on the Tailscale network,associating them with domain names of the form <mynode>.<mydomain>.<root>.If it is asked to resolve a domain that is not of that form,it delegates to upstream nameservers if any are set.

funcNew

func New(logflogger.Logf, linkSelForwardLinkSelector, dialer *tsdial.Dialer, health *health.Tracker, knobs *controlknobs.Knobs) *Resolver

New returns a new resolver.dialer and health must be non-nil.

func (*Resolver)Close

func (r *Resolver) Close()

Close shuts down the resolver and ensures poll goroutines have exited.The Resolver cannot be used again after Close is called.

func (*Resolver)GetUpstreamResolversadded inv1.76.0

func (r *Resolver) GetUpstreamResolvers(namednsname.FQDN) []*dnstype.Resolver

GetUpstreamResolvers returns the resolvers that would be used to resolvethe given FQDN.

func (*Resolver)HandlePeerDNSQueryadded inv1.54.0

func (r *Resolver) HandlePeerDNSQuery(ctxcontext.Context, q []byte, fromnetip.AddrPort, allowName func(namestring)bool) (res []byte, errerror)

HandlePeerDNSQuery handles a DNS query that arrived from a peervia the peerapi's DoH server. This is used when the localnode is being an exit node or an app connector.

The provided allowName callback is whether a DNS query for a name(as found by parsing q) is allowed.

In most (all?) cases, err will be nil. A bogus DNS query q willstill result in a response DNS packet (saying there's a failure)and a nil error.TODO: figure out if we even need an error result.

func (*Resolver)Queryadded inv1.26.0

func (r *Resolver) Query(ctxcontext.Context, bs []byte, familystring, fromnetip.AddrPort) ([]byte,error)

func (*Resolver)SetConfig

func (r *Resolver) SetConfig(cfgConfig)error

func (*Resolver)TestOnlySetHook

func (r *Resolver) TestOnlySetHook(hook func(Config))

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp