resolver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package resolver provides the implementation of Penne resolvers

Index

Constants

View Source
const (
	// DefaultIteratorMaxRR indicates the number of records
	// the Iterator lookuper will cache.
	DefaultIteratorMaxRR = 1024
)

Variables

This section is empty.

Functions

func MakeResolvers

func MakeResolvers(conf []Config, debug map[string]slog.LogLevel,
	opts *Options) ([]string, map[string]*Resolver, error)

MakeResolvers builds resolvers from a Config slice.

Types

type Config

type Config struct {
	// Name is the unique name of this [Resolver]
	Name string `yaml:""`
	// Next is the name of the resolver to use if the Suffixes restriction
	// isn't satisfied.
	Next string `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// Debug indicates the requests passing through this [Resolver] should be logged or not.
	Debug bool `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// OmitSubNet indicates requests reaching out to remote servers should omit
	// EDNS0 SUBNET information.
	OmitSubNet bool `yaml:"omit_subnet,omitempty" toml:",omitempty" json:",omitempty"`

	// DisableAAAA indicates that this [Resolver] will discard AAAA entries
	DisableAAAA bool `yaml:"disable_aaaa,omitempty" toml:",omitempty" json:",omitempty"`

	// Iterative indicates that this [Resolver] will go straight to the DNS
	// root servers and ask the authoritative servers for the answers.
	Iterative bool `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
	// IterativeMaxRR indicates the maximum number of glue records the Iterative Resolver
	// will cache.
	IterativeMaxRR uint `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// Recursive indicates that this [Resolver] will ask servers to perform
	// recursive lookups.
	Recursive bool `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// Servers is a list of DNS servers to use for forwarding or iterative resolution.
	// If this [Resolver] is designated as iterative and no servers are provided,
	// a built-in list of root DNS servers will be used.
	Servers []string `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// Workers indicates how many parallel outward connections we allow
	// from this resolver. It applies to iterative and forwarding resolvers.
	Workers uint `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// Suffixes indicate what domains will this [Resolver] handle. Globbing patterns allowed.
	Suffixes []string `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// Rewrites is a list of query name rewrites to be done by this [Resolver].
	Rewrites []RewriteConfig `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
}

Config describes a Resolver.

func (Config) New added in v0.0.4

func (rc Config) New(next resolver.Exchanger, opts *Options) (*Resolver, error)

New creates a new Resolver.

func (Config) NewError added in v0.0.8

func (rc Config) NewError(format string, args ...any) *Error

NewError creates a new Error using the Config's name.

func (*Config) SetDefaults added in v0.0.8

func (rc *Config) SetDefaults()

SetDefaults fills gaps in the Config.

func (Config) WrapError added in v0.0.8

func (rc Config) WrapError(err error, format string, args ...any) error

WrapError creates a new Error using the Config's name, wrapping another error.

type Error

type Error struct {
	Resolver string
	Reason   string
	Err      error
}

Error is an error that references the name of a Resolver

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap

func (e Error) Unwrap() error

type Exchanger added in v0.0.9

type Exchanger = resolver.Exchanger

Exchanger is an alias of resolver.Exchanger for module shadowing support.

type ExchangerFunc added in v0.0.9

type ExchangerFunc = resolver.ExchangerFunc

ExchangerFunc is an alias of resolver.ExchangerFunc for module shadowing support.

type Options added in v0.0.4

type Options struct {
	Logger slog.Logger

	SingleFlight time.Duration `default:"1s"`

	TLSConfig *tls.Config
}

Options contains information used to assemble all [Resolver]s.

func (*Options) NewClient added in v0.0.4

func (opts *Options) NewClient(net string) client.Client

NewClient uses the Options to create a new dns.Client.

func (*Options) SetDefaults added in v0.0.4

func (opts *Options) SetDefaults()

SetDefaults fills any gap in the Options.

type Resolver

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

Resolver is a custom resolver.Exchanger.

func (*Resolver) Cancel added in v0.1.2

func (r *Resolver) Cancel(err error) bool

Cancel initiates a shut down of Resolver's Worker.

func (*Resolver) Exchange added in v0.0.9

func (r *Resolver) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

Exchange implements the resolver.Exchanger interface.

func (*Resolver) Lookup added in v0.0.9

func (r *Resolver) Lookup(ctx context.Context, qName string, qType uint16) (*dns.Msg, error)

Lookup implements the resolver.Lookuper interface.

func (*Resolver) Name added in v0.0.4

func (r *Resolver) Name() string

Name returns the name of the resolver.

func (*Resolver) SetFallback added in v0.0.9

func (r *Resolver) SetFallback(last resolver.Exchanger) bool

SetFallback sets the exchanger to use next if it doesn't have one already set from Config.

func (*Resolver) Shutdown added in v0.1.2

func (r *Resolver) Shutdown(ctx context.Context) error

Shutdown initiates a shut down of Resolver's Worker, and waits until they are done or the given context expires.

func (*Resolver) Start added in v0.1.2

func (r *Resolver) Start(ctx context.Context) error

Start starts the Resolver's worker.

func (*Resolver) String added in v0.0.4

func (r *Resolver) String() string

type RewriteConfig

type RewriteConfig struct {
	// From is a globbing pattern to match and capture.
	From string `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
	// To is the rewrite template for entries that match the `From` pattern.
	To string `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
	// Final indicates that entries matching this From shouldn't continue
	// to the next rewrite rule.
	Final bool
}

RewriteConfig describes an expression used to alter a request.

Jump to

Keyboard shortcuts

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