router

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Fetch(req *dns.Msg, fetcher cacheFetcher) (*dns.Msg, error)
}

func NewCache

func NewCache(cfg CacheCfg) Cache

type CacheCfg

type CacheCfg struct {
	Size   int
	MinTTL uint32
	MaxTTL uint32
}

type FileSource

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

func NewFileSource

func NewFileSource(filepath string, opts ...FileSourceOption) (*FileSource, error)

func (*FileSource) Close

func (s *FileSource) Close() error

func (*FileSource) Domains

func (s *FileSource) Domains(_ context.Context) ([]string, error)

func (*FileSource) Watch

func (s *FileSource) Watch(notify WatchNotifier)

type FileSourceOption

type FileSourceOption func(s *FileSource)

func WithFileSourceReloadInterval

func WithFileSourceReloadInterval(interval time.Duration) FileSourceOption

type Route

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

func NewRoute

func NewRoute(opts ...RouteOption) *Route

func (*Route) Close

func (r *Route) Close() error

func (*Route) Domains

func (r *Route) Domains(ctx context.Context) ([]string, error)

func (*Route) Exchange

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

func (*Route) Name

func (r *Route) Name() string

func (*Route) Subscribe

func (r *Route) Subscribe(fn RouteSubscribeFn)

type RouteOption

type RouteOption func(r *Route)

func WithBannedQTypes added in v2.1.0

func WithBannedQTypes(types ...uint16) RouteOption

func WithRouteCache

func WithRouteCache(cfg CacheCfg) RouteOption

func WithRouteDNS64

func WithRouteDNS64(d64 *dns64.DNS64) RouteOption

func WithRouteFinalize

func WithRouteFinalize(finalize bool) RouteOption

func WithRouteName

func WithRouteName(name string) RouteOption

func WithRouteSource

func WithRouteSource(sources ...Source) RouteOption

func WithRouteUpstreams

func WithRouteUpstreams(upstreams ...upstream.Upstream) RouteOption

type RouteSubscribeFn

type RouteSubscribeFn func(routeName string)

type RouteTrie

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

func NewRouteTrie

func NewRouteTrie() *RouteTrie

func (*RouteTrie) Find

func (t *RouteTrie) Find(domain string) *Route

func (*RouteTrie) Insert

func (t *RouteTrie) Insert(domain string, route *Route)

type Router

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

func NewRouter

func NewRouter(routes ...*Route) (*Router, error)

func (*Router) Close

func (r *Router) Close() error

func (*Router) Exchange

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

type Source

type Source interface {
	Domains(ctx context.Context) ([]string, error)
	Watch(notify WatchNotifier)
	Close() error
}

type StaticSource

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

func NewStaticSource

func NewStaticSource(domains []string) (*StaticSource, error)

func (*StaticSource) Close

func (s *StaticSource) Close() error

func (*StaticSource) Domains

func (s *StaticSource) Domains(_ context.Context) ([]string, error)

func (*StaticSource) Watch

func (s *StaticSource) Watch(_ WatchNotifier)

type TrieNode

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

type WatchNotifier

type WatchNotifier func()

Jump to

Keyboard shortcuts

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