filter

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CacheTTL = 12 * time.Hour

CacheTTL is the duration before a domain name resolution is evict form the cache.

Variables

View Source
var ErrHostNotAllowed = errors.New("host not allowed")

ErrHostNotAllowed is returned when a host is not allowed.

View Source
var ErrHostRejected = errors.New("rejected host")

ErrHostRejected is returned when the host has been flagged as unwanted.

Functions

This section is empty.

Types

type Approver

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

An Approver is able to check if an host is allowed or not.

func NewAppover

func NewAppover(stricts []string, cidrs []string) (*Approver, error)

NewAppover returns a new Approver where `stricts' is a slice od allowed hosts and cidrs a slice of allowed IP ranges.

func (*Approver) Allowed

func (f *Approver) Allowed(ctx context.Context, host string) error

Allowed checks if the host `host:port' is allowed or not. Use `errors.Is(err, ErrHostNotAllowed)' to check the error's nature.

type NameResolver

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

A NameResolver is used to filter IPs using name resolution.

func NewNameResolver

func NewNameResolver(allows []string) (*NameResolver, error)

NewNameResolver return a new NameResolver.

func (*NameResolver) Resolve

func (r *NameResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)

Resolve returns the ip for the given domain name.

Jump to

Keyboard shortcuts

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