tsdns

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package tsdns provides a Resolver capable of resolving domains on a Tailscale network.

Index

Constants

This section is empty.

Variables

View Source
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 NewMap

func NewMap(initNameToIP map[string]netaddr.IP, rootDomains []string) *Map

NewMap returns a new Map with name to address mapping given by nameToIP.

func (*Map) Pretty added in v1.0.0

func (m *Map) Pretty() string

func (*Map) PrettyDiffFrom added in v1.0.0

func (m *Map) PrettyDiffFrom(old *Map) string

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

func (r *Resolver) EnqueueRequest(request Packet) error

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

func (r *Resolver) NextResponse() (Packet, error)

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

func (r *Resolver) Resolve(domain string, tp dns.Type) (netaddr.IP, dns.RCode, error)

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

func (r *Resolver) ResolveReverse(ip netaddr.IP) (string, dns.RCode, error)

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) SetMap

func (r *Resolver) SetMap(m *Map)

SetMap sets the resolver's DNS map, taking ownership of it.

func (*Resolver) SetUpstreams added in v1.2.0

func (r *Resolver) SetUpstreams(upstreams []net.Addr)

SetUpstreams sets the addresses of the resolver's upstream nameservers, taking ownership of the argument.

func (*Resolver) Start added in v1.0.0

func (r *Resolver) Start() error

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.

Jump to

Keyboard shortcuts

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