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) (netaddr.IP, dns.RCode, error)
- func (r *Resolver) SetMap(m *Map)
- func (r *Resolver) SetNameservers(nameservers []string)
- func (r *Resolver) Start()
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 ¶
NewResolver constructs a resolver associated with the given root domain.
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. The domain name must not have a trailing period.
func (*Resolver) SetNameservers ¶ added in v1.0.0
SetUpstreamNameservers sets the addresses of the resolver's upstream nameservers, taking ownership of the argument. The addresses should be strings of the form ip:port, matching what Dial("udp", addr) expects as addr.