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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResponseNil            = errors.New("response must not be nil")
	ErrResponseEmpty          = errors.New("neither hosts nor addresses are set in the response")
	ErrUnmatchedResolvedHosts = errors.New("resolved hosts do not match")
	ErrUnmatchedResolvedIPs   = errors.New("resolved IPs do not match")
)
View Source
var (
	ErrNotADNSPInitiator = errors.New("the given initiator is not a DNS initiator")
)

Functions

This section is empty.

Types

type CheckFilterFunc

type CheckFilterFunc func(resp *Response) error

func (CheckFilterFunc) Matches

func (f CheckFilterFunc) Matches(resp *Response) error

type Initiator

type Initiator interface {
	Do(ctx context.Context, resolver Resolver) (*Response, error)
}

func AorAAAAInitiator

func AorAAAAInitiator(logger logging.Logger, args ...rules.Param) (Initiator, error)

func CheckForRule

func CheckForRule(rule *rules.Check, logger logging.Logger) (Initiator, error)

func PTRInitiator

func PTRInitiator(logger logging.Logger, args ...rules.Param) (Initiator, error)

type InitiatorFunc

type InitiatorFunc func(ctx context.Context, resolver Resolver) (*Response, error)

func (InitiatorFunc) Do

func (f InitiatorFunc) Do(ctx context.Context, resolver Resolver) (*Response, error)

type MockResolver

type MockResolver struct {
	LookupAddrDelegate func(ctx context.Context, addr string) (names []string, err error)
	LookupHostDelegate func(ctx context.Context, host string) (addrs []net.IP, err error)
}

func (*MockResolver) LookupA added in v0.7.0

func (r *MockResolver) LookupA(ctx context.Context, host string) (addrs []net.IP, err error)

func (*MockResolver) LookupPTR added in v0.7.0

func (r *MockResolver) LookupPTR(ctx context.Context, addr string) (names []string, err error)

func (*MockResolver) ResolverForModule added in v0.7.0

func (r *MockResolver) ResolverForModule(string) (Resolver, error)

type Resolver

type Resolver interface {
	// LookupA looks up the given host using the corresponding query protocol.
	// It returns a slice of that host's addresses.
	LookupA(ctx context.Context, host string) (addrs []net.IP, err error)

	// LookupPTR performs a reverse lookup for the given address, returning a list
	// of names mapping to that address.
	//
	// The returned names are validated to be properly formatted presentation-format
	// domain names. If the response contains invalid names, those records are filtered
	// out and an error will be returned alongside the the remaining results, if any.
	LookupPTR(ctx context.Context, addr string) (names []string, err error)
}

type Response

type Response struct {
	Hosts     []string
	Addresses []net.IP
}

type ValidationChain

type ValidationChain []Validator

func ValidatorsForRule

func ValidatorsForRule(rule *rules.Check) (filters ValidationChain, err error)

func (*ValidationChain) Add

func (c *ValidationChain) Add(v Validator)

func (ValidationChain) Len

func (c ValidationChain) Len() int

func (ValidationChain) Matches

func (c ValidationChain) Matches(resp *Response) error

type Validator

type Validator interface {
	Matches(resp *Response) error
}

func InCIDRResponseFilter

func InCIDRResponseFilter(args ...rules.Param) (Validator, error)

func NotEmptyResponseFilter added in v0.7.0

func NotEmptyResponseFilter(...rules.Param) (Validator, error)

func ResolvedHostResponseFilter

func ResolvedHostResponseFilter(args ...rules.Param) (Validator, error)

func ResolvedIPResponseFilter

func ResolvedIPResponseFilter(args ...rules.Param) (Validator, error)

Jump to

Keyboard shortcuts

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