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

dns

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dns provides a local DNS server for dynamic instance resolution. It enables Caddy to resolve instance names to IP addresses at request time.

Index

Constants

View Source
const (
	// DefaultPort is the default port for the local DNS server.
	// Using 0 means the OS will assign a random available port, preventing
	// conflicts on shared development machines.
	DefaultPort = 0

	// Suffix is the domain suffix used for instance resolution.
	// Queries like "my-instance.hypeman.internal" will be resolved.
	Suffix = "hypeman.internal"

	// DefaultTTL is the TTL for DNS responses in seconds.
	// Keep it low since instance IPs can change.
	DefaultTTL = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InstanceResolver

type InstanceResolver interface {
	// ResolveInstanceIP resolves an instance name or ID to its IP address for DNS.
	ResolveInstanceIP(ctx context.Context, nameOrID string) (string, error)
}

InstanceResolver provides instance IP resolution. This interface is implemented by the instances package.

type Server

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

Server provides DNS-based instance resolution for Caddy. It listens on a local port and responds to A record queries for instances in the form "<instance>.hypeman.internal".

func NewServer

func NewServer(resolver InstanceResolver, port int, log *slog.Logger) *Server

NewServer creates a new DNS server for instance resolution. If port is 0, the OS will assign a random available port. The actual port can be retrieved with Port() after Start() is called.

func (*Server) IsRunning

func (s *Server) IsRunning() bool

IsRunning returns true if the DNS server is running.

func (*Server) Port

func (s *Server) Port() int

Port returns the port the DNS server is listening on.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the DNS server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the DNS server.

Jump to

Keyboard shortcuts

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