dns

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WithTTL = func(ttl time.Duration) CacheOption {
		return func(cfg *cacheConfig) {
			if ttl > 0 {
				cfg.ttl = ttl
			}
		}
	}
	WithInitialSize = func(initialSize int) CacheOption {
		return func(cfg *cacheConfig) {
			if initialSize >= minimumInitialSize {
				cfg.initialSize = initialSize
			}
		}
	}
)
View Source
var ErrNoAnswerForQuestion = errors.New("cannot answer given question")

Functions

func HostnameQuestionFilter added in v0.7.0

func HostnameQuestionFilter(qType uint16) func(args ...rules.Param) (QuestionPredicate, error)

func ParseInAddrArpa

func ParseInAddrArpa(inAddrArpa string) net.IP

func RRHeader added in v0.7.0

func RRHeader(ttl time.Duration, q Question) mdns.RR_Header

Types

type Cache

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

func NewCache

func NewCache(opts ...CacheOption) *Cache

func (*Cache) ForwardLookup

func (c *Cache) ForwardLookup(host string) net.IP

func (*Cache) PutRecord

func (c *Cache) PutRecord(host string, address net.IP)

func (*Cache) ReverseLookup

func (c *Cache) ReverseLookup(address net.IP) (host string, miss bool)

type CacheHandler added in v0.7.0

type CacheHandler struct {
	Cache    ResourceRecordCache
	TTL      time.Duration
	Fallback Handler
}

func (*CacheHandler) AnswerDNSQuestion added in v0.7.0

func (h *CacheHandler) AnswerDNSQuestion(q Question) (rr ResourceRecord, err error)

type CacheOption

type CacheOption func(cfg *cacheConfig)

type ConditionalResolver added in v0.7.0

type ConditionalResolver struct {
	IPResolver
	Predicates []QuestionPredicate
}

func (ConditionalResolver) Matches added in v0.7.0

func (c ConditionalResolver) Matches(q Question) bool

type Handler added in v0.7.0

type Handler interface {
	AnswerDNSQuestion(q Question) (ResourceRecord, error)
}

func FallbackHandler added in v0.7.0

func FallbackHandler(handler Handler, resolver IPResolver, ttl time.Duration) Handler

type HandlerFunc added in v0.7.0

type HandlerFunc func(q Question) (ResourceRecord, error)

func (HandlerFunc) AnswerDNSQuestion added in v0.7.0

func (f HandlerFunc) AnswerDNSQuestion(q Question) (ResourceRecord, error)

type IPResolver

type IPResolver interface {
	Lookup(host string) net.IP
}

func IncrementalResolverForArgs added in v0.7.0

func IncrementalResolverForArgs(args []rules.Param) (IPResolver, error)

func RandomIPResolverForArgs added in v0.7.0

func RandomIPResolverForArgs(args []rules.Param) (IPResolver, error)

func ResolverForRule added in v0.7.0

func ResolverForRule(rule *rules.SingleResponsePipeline) (IPResolver, error)

func StaticIPResolverForArgs added in v0.7.0

func StaticIPResolverForArgs(args []rules.Param) (IPResolver, error)

type IPResolverFunc

type IPResolverFunc func(host string) net.IP

func (IPResolverFunc) Lookup

func (f IPResolverFunc) Lookup(host string) net.IP

type IncrementalIPResolver added in v0.7.0

type IncrementalIPResolver struct {
	Offset uint32
	CIDR   *net.IPNet
	// contains filtered or unexported fields
}

func NewIncrementalIPResolver added in v0.7.0

func NewIncrementalIPResolver(cidr *net.IPNet) *IncrementalIPResolver

func (*IncrementalIPResolver) Lookup added in v0.7.0

func (i *IncrementalIPResolver) Lookup(string) net.IP

type Options added in v0.7.0

type Options struct {
	Rules   []string
	Cache   ResourceRecordCache
	Default IPResolver
	TTL     time.Duration
}

func OptionsFromLifecycle added in v0.7.0

func OptionsFromLifecycle(startupSpec *endpoint.StartupSpec) (*Options, error)

type Question added in v0.7.0

type Question mdns.Question

type QuestionPredicate added in v0.7.0

type QuestionPredicate interface {
	Matches(q Question) bool
}

func QuestionPredicatesForRoutingRule added in v0.7.0

func QuestionPredicatesForRoutingRule(rule *rules.SingleResponsePipeline) (predicates []QuestionPredicate, err error)

type QuestionPredicateFunc added in v0.7.0

type QuestionPredicateFunc func(q Question) bool

func (QuestionPredicateFunc) Matches added in v0.7.0

func (f QuestionPredicateFunc) Matches(q Question) bool

type RandomIPResolver added in v0.7.0

type RandomIPResolver struct {
	Random *rand.Rand
	CIDR   *net.IPNet
	// contains filtered or unexported fields
}

func NewRandomIPResolver added in v0.7.0

func NewRandomIPResolver(cidr *net.IPNet) *RandomIPResolver

nolint:gosec // pseudo-random is desired for this purpose

func (*RandomIPResolver) Lookup added in v0.7.0

func (r *RandomIPResolver) Lookup(string) net.IP

type Record

type Record struct {
	Name    string
	Address net.IP
}

type ResourceRecord added in v0.7.0

type ResourceRecord mdns.RR

type ResourceRecordCache added in v0.7.0

type ResourceRecordCache interface {
	PutRecord(host string, address net.IP)
	ForwardLookup(host string) net.IP
	ReverseLookup(address net.IP) (host string, miss bool)
}

type RuleHandler added in v0.7.0

type RuleHandler struct {
	TTL time.Duration
	// contains filtered or unexported fields
}

func (RuleHandler) AnswerDNSQuestion added in v0.7.0

func (r RuleHandler) AnswerDNSQuestion(q Question) (ResourceRecord, error)

func (*RuleHandler) RegisterRule added in v0.7.0

func (r *RuleHandler) RegisterRule(rawRule string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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