Help us shape the future of Go! Take the 2026 Go Developer Survey

magicdns

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package magicdns is the agent's DNS resolver. It answers names of mesh nodes (<node>.<domain>) from the netmap and forwards split-DNS domains to their configured resolvers. In TUN mode the agent serves it at Addr, intercepting queries before they reach WireGuard, so no socket needs to be bound and nothing leaves the machine for mesh names.

Index

Constants

This section is empty.

Variables

View Source
var Addr = netip.MustParseAddr("100.100.100.100")

Addr is where the resolver answers. It lies inside the default mesh prefix and is never assigned to a node.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Domain is the suffix of node names, e.g. "mesh.internal"; empty
	// disables answering for nodes.
	Domain string
	// Nodes maps node names to addresses.
	Nodes map[string]netip.Addr
	Split []Split
}

Config is the resolver's view of the mesh.

type Resolver

type Resolver struct {
	// Dial connects to upstream resolvers of split domains; nil uses the
	// host network.
	Dial func(ctx context.Context, network, address string) (net.Conn, error)
	// contains filtered or unexported fields
}

Resolver answers DNS queries. It is safe for concurrent use.

func (*Resolver) Domains

func (r *Resolver) Domains() []string

Domains returns the domains the resolver is authoritative for or forwards, for configuring the OS: queries for these should be sent to Addr.

func (*Resolver) Handle

func (r *Resolver) Handle(ctx context.Context, query []byte) []byte

Handle answers one DNS message (UDP wire format). It returns nil for messages that are not worth answering (not a query, unparseable).

func (*Resolver) Lookup

func (r *Resolver) Lookup(name string) (netip.Addr, bool)

Lookup resolves a mesh name: "node" or "node.<domain>".

func (*Resolver) SetConfig

func (r *Resolver) SetConfig(c Config)

SetConfig replaces the resolver's configuration.

type Split

type Split struct {
	Domain    string
	Resolvers []netip.AddrPort
}

Split sends queries for Domain (and its subdomains) to Resolvers.

Jump to

Keyboard shortcuts

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