sources

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader added in v0.3.0

type Downloader interface {
	// Download all sources in Lists.
	Download(*Lists) (*set.Set[string], error)
}

A Downloader is used to download a set of source lists.

func NewDownloader added in v0.3.0

func NewDownloader(fwd *agent.Forward, logger output.Logger) Downloader

NewDownloader creates a new Downloader for downloading source lists.

type Getter added in v0.3.0

type Getter interface {
	// Get source and extract its domains into a Set.
	Get(source string) (*set.Set[string], error)
}

A Getter is used to download a single source list.

func NewGetter added in v0.3.0

func NewGetter(logger output.Logger, fwd *agent.Forward, ex extract.Extractor) Getter

NewGetter creates a new Getter, using Extractor ex to extract domains.

type Lists

type Lists struct {
	Suspicious  []string `json:"suspicious"`
	Advertising []string `json:"advertising"`
	Tracking    []string `json:"tracking"`
	Malicious   []string `json:"malicious"`
	Miners      []string `json:"miners"`
}

Lists represents the embedded JSON file containing default source lists.

func Defaults

func Defaults() *Lists

Defaults returns the default set of source lists.

The default set of source lists are embedded as statics/sources.json which we then simply unmarshal at runtime.

func (*Lists) All

func (d *Lists) All() []string

All returns a combined list of all default source lists.

func (*Lists) Len

func (d *Lists) Len() int

Len returns the combined number of default source lists.

type Sets added in v0.3.0

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

Sets enables efficient look-ups of whether a domain should be allowable or blocked.

func New added in v0.3.0

func New(logger output.Logger, cc *agent.CoreConfig) *Sets

New returns a Sets pre-filled according to cc.

func (*Sets) Allow added in v0.3.0

func (s *Sets) Allow(domain string) bool

Allow indicates whether domain is on the explicit allow-list.

func (*Sets) BlockByMatch added in v0.3.0

func (s *Sets) BlockByMatch(domain string) bool

BlockByMatch indicates whether domain is on the explicit block-list.

func (*Sets) BlockBySuffix added in v0.3.0

func (s *Sets) BlockBySuffix(domain string) bool

BlockBySuffix indicates whether domain is on the suffix block-list.

func (*Sets) Size added in v0.3.0

func (s *Sets) Size() (int, int, int)

Size returns the number of items in the allow, block, suffix sets.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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