Documentation ¶
Overview ¶
Package tsdns provides a Resolver capable of resolving domains on a Tailscale network.
Index ¶
- Variables
- type Map
- type Packet
- type Resolver
- func (r *Resolver) Close()
- func (r *Resolver) EnqueueRequest(request Packet) error
- func (r *Resolver) NextResponse() (Packet, error)
- func (r *Resolver) Resolve(domain string, tp dns.Type) (netaddr.IP, dns.RCode, error)
- func (r *Resolver) ResolveReverse(ip netaddr.IP) (string, dns.RCode, error)
- func (r *Resolver) SetMap(m *Map)
- func (r *Resolver) SetUpstreams(upstreams []net.Addr)
- func (r *Resolver) Start() error
- type ResolverConfig
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("closed")
ErrClosed indicates that the resolver has been closed and readers should exit.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is all the data Resolver needs to resolve DNS queries within the Tailscale network.
func (*Map) PrettyDiffFrom ¶ added in v1.0.0
type Packet ¶ added in v1.0.0
type Packet struct { // Payload is the application layer DNS payload. // Resolver assumes ownership of the request payload when it is enqueued // and cedes ownership of the response payload when it is returned from NextResponse. Payload []byte // Addr is the source address for a request and the destination address for a response. Addr netaddr.IPPort }
Packet represents a DNS payload together with the address of its origin.
type Resolver ¶
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.
func NewResolver ¶
func NewResolver(config ResolverConfig) *Resolver
NewResolver constructs a resolver associated with the given root domain. The root domain must be in canonical form (with a trailing period).
func (*Resolver) Close ¶ added in v1.0.0
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) EnqueueRequest ¶ added in v1.0.0
EnqueueRequest places the given DNS request in the resolver's queue. It takes ownership of the payload and does not block. If the queue is full, the request will be dropped and an error will be returned.
func (*Resolver) NextResponse ¶ added in v1.0.0
NextResponse returns a DNS response to a previously enqueued request. It blocks until a response is available and gives up ownership of the response payload.
func (*Resolver) Resolve ¶
Resolve maps a given domain name to the IP address of the host that owns it, if the IP address conforms to the DNS resource type given by tp (one of A, AAAA, ALL). The domain name must be in canonical form (with a trailing period).
func (*Resolver) ResolveReverse ¶ added in v1.2.0
ResolveReverse returns the unique domain name that maps to the given address. The returned domain name is in canonical form (with a trailing period).
func (*Resolver) SetUpstreams ¶ added in v1.2.0
SetUpstreams sets the addresses of the resolver's upstream nameservers, taking ownership of the argument.
type ResolverConfig ¶ added in v1.2.0
type ResolverConfig struct { // Logf is the logger to use throughout the Resolver. Logf logger.Logf // Forward determines whether the resolver will forward packets to // nameservers set with SetUpstreams if the domain name is not of a Tailscale node. Forward bool }
ResolverConfig is the set of configuration options for a Resolver.