dnsserver

package
v1.37.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package dnsserver is lerd's built-in DNS server. It reads the dnsmasq-style config directory lerd has always written, so the format and every tool that rewrites lerd.conf stay the same.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addrs

type Addrs struct {
	V4 []net.IP
	V6 []net.IP
}

Addrs are the answers for every name under one domain.

type Conf

type Conf struct {
	Port    int
	Domains map[string]Addrs
	// Upstreams answer every other name, as host:port. A resolver that routes
	// all queries here (systemd-resolved with ~.) relies on it.
	Upstreams []string
	// Routes sends names under a domain to that domain's own servers, from
	// server=/d/ip. An empty route refuses the names instead of forwarding, and
	// a defaultUpstreams entry stands for the default upstreams (server=/d/#).
	Routes map[string][]string
	// LogQueries prints every query to stderr, as dnsmasq's log-queries did.
	LogQueries bool
	// Unsupported holds the lines this server does not act on, so a directive
	// someone added by hand for dnsmasq is reported rather than lost.
	Unsupported []string
}

Conf is the subset of dnsmasq's syntax this server acts on: port=, address=, server= (plain and per-domain) and log-queries.

func ParseConf

func ParseConf(data []byte) (Conf, error)

ParseConf reads a lerd.conf. Directives it does not serve, and lines it cannot parse, are skipped so a newer config never stops an older server; the ones it does not recognise are listed in Unsupported.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server answers A and AAAA queries for the domains in a config directory, reloading it whenever a file in it changes.

func New

func New(dir string) *Server

New returns a Server backed by the config directory dir.

func (*Server) Port

func (s *Server) Port() int

Port is the port the config asks for, or 0 when it names none.

func (*Server) ServeTCP

func (s *Server) ServeTCP(ln net.Listener, ready func()) error

ServeTCP serves on ln until Shutdown. DNS clients fall back to TCP for large answers, and lerd's own diagnostics probe the port over TCP.

func (*Server) ServeUDP

func (s *Server) ServeUDP(pc net.PacketConn, ready func()) error

ServeUDP serves on pc until Shutdown. ready, when non-nil, runs once the socket is accepting queries.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown stops every running Serve call.

Jump to

Keyboard shortcuts

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