middleware

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List() (list []string)

List return names of handlers.

func LoadExternalPlugins added in v1.1.0

func LoadExternalPlugins()

LoadExternalPlugins load external plugins into chain.

func Ready added in v1.1.0

func Ready() bool

Ready return true if middleware setup was done.

func Register

func Register(name string, new func(*config.Config) Handler)

Register a middleware.

func RegisterAt added in v1.1.0

func RegisterAt(name string, new func(*config.Config) Handler, idx int)

RegisterAt a middleware at an index.

func RegisterBefore added in v1.1.0

func RegisterBefore(name string, new func(*config.Config) Handler, before string)

RegisterBefore a middleware before another middleware.

func Setup

func Setup(cfg *config.Config)

Setup handlers.

Types

type Chain added in v1.1.0

type Chain struct {
	Writer  ResponseWriter
	Request *dns.Msg
	// contains filtered or unexported fields
}

Chain type.

func NewChain added in v1.1.0

func NewChain(handlers []Handler) *Chain

NewChain return new fresh chain.

func (*Chain) Cancel added in v1.1.0

func (ch *Chain) Cancel()

(*Chain).Cancel cancel next calls.

func (*Chain) CancelWithRcode added in v1.1.7

func (ch *Chain) CancelWithRcode(rcode int, do bool)

(*Chain).CancelWithRcode cancelWithRcode next calls with rcode.

func (*Chain) Next added in v1.1.0

func (ch *Chain) Next(ctx context.Context)

(*Chain).Next next call next dns handler in the chain.

func (*Chain) Reset added in v1.1.0

func (ch *Chain) Reset(w dns.ResponseWriter, r *dns.Msg)

(*Chain).Reset reset the chain variables.

type Handler added in v1.1.0

type Handler interface {
	Name() string
	ServeDNS(context.Context, *Chain)
}

Handler interface.

func Get

func Get(name string) Handler

Get return a handler by name.

func Handlers

func Handlers() []Handler

Handlers return registered handlers.

type HandlerFunc added in v1.5.0

type HandlerFunc func(context.Context, *Chain)

HandlerFunc type adapter to allow the use of ordinary functions as handlers.

func (HandlerFunc) Name added in v1.5.0

func (f HandlerFunc) Name() string

(HandlerFunc).Name name returns the handler name.

func (HandlerFunc) ServeDNS added in v1.5.0

func (f HandlerFunc) ServeDNS(ctx context.Context, ch *Chain)

(HandlerFunc).ServeDNS serveDNS calls f(ctx, ch).

type ResponseWriter added in v1.1.0

type ResponseWriter interface {
	dns.ResponseWriter
	Msg() *dns.Msg
	Rcode() int
	Written() bool
	Reset(dns.ResponseWriter)
	Proto() string
	RemoteIP() net.IP
	Internal() bool
}

ResponseWriter implement of dns.ResponseWriter.

Directories

Path Synopsis
Package hostsfile implements a high-performance hosts file resolver with advanced features like wildcard support and automatic reloading
Package hostsfile implements a high-performance hosts file resolver with advanced features like wildcard support and automatic reloading
Package kubernetes - Simple DNS cache
Package kubernetes - Simple DNS cache
Package reflex detects DNS amplification/reflection attacks.
Package reflex detects DNS amplification/reflection attacks.

Jump to

Keyboard shortcuts

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