Documentation
¶
Overview ¶
Package horizon implements entrypoints based on the network they belong to
Index ¶
- func DNSRemoteAddr(rw dns.ResponseWriter) (netip.Addr, error)
- func ForbiddenExchange(_ context.Context, req *dns.Msg) (*dns.Msg, error)
- func ForbiddenHTTP(rw http.ResponseWriter, _ *http.Request)
- func HTTPRemoteAddr(req *http.Request) (netip.Addr, error)
- func HandleForbiddenExchange(rw dns.ResponseWriter, req *dns.Msg)
- func NewContextKey(label string) *core.ContextKey[Match]
- type Config
- type Configs
- type Horizon
- func (z *Horizon) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)
- func (z *Horizon) InRange(addr netip.Addr) bool
- func (z *Horizon) Lookup(ctx context.Context, qName string, qType uint16) (*dns.Msg, error)
- func (z *Horizon) Match(addr netip.Addr) (netip.Prefix, bool)
- func (z *Horizon) Name() string
- func (z *Horizon) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (z *Horizon) SetDefaults() error
- func (z *Horizon) String() string
- type Horizons
- func (s *Horizons) Append(z *Horizon) error
- func (s *Horizons) AppendNew(hc Config, h http.Handler, e resolver.Exchanger) error
- func (s Horizons) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)
- func (s Horizons) Get(name string) *Horizon
- func (s *Horizons) Len() int
- func (s Horizons) Match(addr netip.Addr) (*Horizon, netip.Prefix, bool)
- func (s Horizons) MatchDNSRequest(rw dns.ResponseWriter) (*Horizon, Match, bool)
- func (s Horizons) MatchHTTPRequest(req *http.Request) (*Horizon, Match, bool)
- func (s Horizons) ServeDNS(rw dns.ResponseWriter, req *dns.Msg)
- func (s Horizons) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- type Match
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DNSRemoteAddr ¶
func DNSRemoteAddr(rw dns.ResponseWriter) (netip.Addr, error)
DNSRemoteAddr extracts the remote address associated with an dns.ResponseWriter
func ForbiddenExchange ¶
ForbiddenExchange is a resolver.ExchangerFunc that refuses all requests
func ForbiddenHTTP ¶
func ForbiddenHTTP(rw http.ResponseWriter, _ *http.Request)
ForbiddenHTTP is an http.HandlerFunc that always return a 403 error
func HTTPRemoteAddr ¶
HTTPRemoteAddr extracts the remote address associated with an http.Request
func HandleForbiddenExchange ¶
func HandleForbiddenExchange(rw dns.ResponseWriter, req *dns.Msg)
HandleForbiddenExchange is a dns.HandlerFunc that refuses all requests
func NewContextKey ¶ added in v0.3.1
func NewContextKey(label string) *core.ContextKey[Match]
NewContextKey creates a core.ContextKey compatible with Horizons.
Types ¶
type Config ¶
type Config struct { Name string Ranges []netip.Prefix Middleware func(http.Handler) http.Handler ExchangeMiddleware func(resolver.Exchanger) resolver.Exchanger }
Config describe a Horizon
type Configs ¶
type Configs []Config
Configs represents a sorted list of Horizon configurations
type Horizon ¶
type Horizon struct {
// contains filtered or unexported fields
}
Horizon is one horizon
func (*Horizon) Exchange ¶
Exchange implements the resolver.Exchanger interface
func (*Horizon) Lookup ¶
Lookup implements the resolver.Lookuper interface
func (*Horizon) ServeHTTP ¶
func (z *Horizon) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface
func (*Horizon) SetDefaults ¶
SetDefaults fills gaps in the Horizon
type Horizons ¶
type Horizons struct { ExchangeContextFunc func(netip.Addr, *dns.Msg) context.Context ExchangeContext context.Context ExchangeTimeoutFunc func(netip.Addr, *dns.Msg) time.Duration ExchangeTimeout time.Duration ContextKey *core.ContextKey[Match] // contains filtered or unexported fields }
Horizons is a list of all known horizons sorted by priority.
func (*Horizons) AppendNew ¶
AppendNew creates a Horizon based on a Config and endpoints. [Config.Name] must be unique.
func (Horizons) Exchange ¶
Exchange implements the resolver.Exchanger interface but requires a Match in the context
func (Horizons) MatchDNSRequest ¶
MatchDNSRequest find the Horizon corresponding to an http.Request and prepares a Match to include in the context.
func (Horizons) MatchHTTPRequest ¶
MatchHTTPRequest find the Horizon corresponding to an http.Request and prepares a Match to include in the context.
func (Horizons) ServeDNS ¶
func (s Horizons) ServeDNS(rw dns.ResponseWriter, req *dns.Msg)
ServeDNS implements the dns.Handler interface
func (Horizons) ServeHTTP ¶
func (s Horizons) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface