dns

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadRecords

func LoadRecords() map[string][]DNSRecord

LoadRecords loads DNS records from environment variables

func ResolveServiceIP

func ResolveServiceIP(serviceName string) (string, error)

ResolveServiceIP attempts to resolve Docker service name to IP

Types

type DNSRecord

type DNSRecord struct {
	Domain     string
	Value      string
	TTL        uint32
	RecordType RecordType
	IsService  bool
	Priority   uint16 // For MX records
}

type Handler

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

func NewHandler

func NewHandler(records map[string][]DNSRecord, relayConfig config.RelayConfig) (*Handler, error)

func (*Handler) ServeDNS

func (h *Handler) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

type RecordType

type RecordType string
const (
	ARecord     RecordType = "A"
	CNAMERecord RecordType = "CNAME"
	MXRecord    RecordType = "MX"
	TXTRecord   RecordType = "TXT"

	// Record separator
	RecordSeparator = "|"
)

type RelayClient added in v1.1.0

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

func NewRelayClient added in v1.1.0

func NewRelayClient(config config.RelayConfig) (*RelayClient, error)

NewRelayClient creates a new RelayClient with the provided configuration. It returns an error if the configuration is invalid.

func (*RelayClient) Relay added in v1.1.0

func (r *RelayClient) Relay(req *dns.Msg) (*dns.Msg, error)

Relay forwards the DNS request to configured upstream nameservers. It attempts each nameserver in sequence until a successful response is received. Returns the first successful response or an error if all nameservers fail.

type RelayError added in v1.1.0

type RelayError struct {
	Server string
	Err    error
	Query  string // DNS query that failed
	Rcode  int    // DNS response code if available
}

func (*RelayError) Error added in v1.1.0

func (e *RelayError) Error() string

Jump to

Keyboard shortcuts

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