tsdns

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2020 License: BSD-3-Clause Imports: 12 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(nameToIP map[string]netaddr.IP) *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(logf logger.Logf, rootDomain string) *Resolver

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

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) (netaddr.IP, dns.RCode, error)

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

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

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

func (*Resolver) SetNameservers added in v1.0.0

func (r *Resolver) SetNameservers(nameservers []string)

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.

func (*Resolver) Start added in v1.0.0

func (r *Resolver) Start()

Jump to

Keyboard shortcuts

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