dns

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dns implements a minimal UDP DNS server that answers A queries for <port>-<id>.<domain> hostnames with a configured IPv4 address. It exists so E2B SDK apps running in sibling Docker containers can resolve sandbox preview URLs to edvabe itself without relying on host-side wildcard DNS (lvh.me, nip.io) that only works from the host.

The server is intentionally single-purpose: it only answers A queries that match the configured base domain. Anything else gets REFUSED so misconfigured clients fail loud rather than silently black-holing unrelated lookups.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Addr     string // UDP listen address, e.g. ":53"
	Domain   string // base domain, e.g. "sbx.edvabe" — queried names must end with this
	Answer   net.IP // IPv4 to return in A records
	Upstream string // host:port to forward non-matching queries to (e.g. "127.0.0.11:53"); empty disables forwarding
	Logger   *slog.Logger
}

Server answers A queries for *.Domain with Answer. Queries for names outside Domain are forwarded to Upstream if set; otherwise REFUSED.

func (*Server) ListenAndServe

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

ListenAndServe blocks until ctx is cancelled or a fatal error occurs.

Jump to

Keyboard shortcuts

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