horizon

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: 11 Imported by: 0

Documentation

Overview

Package horizon provides the implementation for Penne Horizons

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHorizons

func MakeHorizons(conf []Config,
	res map[string]*resolver.Resolver,
	ctxKey *core.ContextKey[horizon.Match]) ([]string, map[string]*Horizon, error)

MakeHorizons builds Horizons from a Config slice, and prepares the resolvers to get back to us when they don't know what else to do.

func NewContextKey

func NewContextKey(name string) *core.ContextKey[horizon.Match]

NewContextKey returns a core.ContextKey to be used to store the horizon.Match in horizon.Horizons

Types

type Config

type Config struct {
	Name string `yaml:"name"`
	Next string `yaml:"next,omitempty" toml:",omitempty" json:",omitempty"`

	AllowForwarding bool `yaml:"allow_forwarding,omitempty" toml:",omitempty" json:",omitempty"`

	Networks []netip.Prefix `yaml:"networks,omitempty" toml:",omitempty" json:",omitempty"`
	Resolver string         `yaml:"resolver,omitempty" toml:",omitempty" json:",omitempty"`
}

Config describes a Horizon

func (Config) New added in v0.0.4

func (hc Config) New(next *Horizon, res *resolver.Resolver,
	ctxKey *core.ContextKey[horizon.Match]) (*Horizon, error)

New creates a new Horizon from the Config

type Error

type Error struct {
	Horizon string
	Reason  string
	Err     error
}

Error is an error that references the name of a Horizon

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap

func (e Error) Unwrap() error

type Horizon

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

A Horizon is a [resolver.Exchanger] for a particular set of networks

func (*Horizon) Exchange added in v0.0.4

func (z *Horizon) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

Exchange handles DNS requests passed from another Horizon.

func (*Horizon) HorizonExchange added in v0.0.4

func (z *Horizon) HorizonExchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

HorizonExchange handles DNS requests directly from the dns.Server when the client belongs in the range.

A Horizon that acts as entry point has to make sure security constraints are checked.

func (*Horizon) HorizonServeHTTP added in v0.0.4

func (z *Horizon) HorizonServeHTTP(rw http.ResponseWriter, req *http.Request)

HorizonServeHTTP handles HTTP requests directly from the http.Server when the client belongs in the range.

A Horizon that acts as entry point has to make sure security constraints are checked.

func (*Horizon) New added in v0.0.4

New creates an assembled horizon.Horizon

func (*Horizon) ServeHTTP added in v0.0.4

func (z *Horizon) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP handles HTTP requests passed from another Horizon.

Jump to

Keyboard shortcuts

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