safesearch

package
v0.0.0-...-b6e3791 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package safesearch contains the implementation of the safe-search filter that uses lists of DNS rewrite rules to enforce safe search.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Cloner is used to clone messages taken from filtering-result cache.
	Cloner *dnsmsg.Cloner

	// Refreshable is the configuration of the refreshable filter-list within
	// the safe-search filter.
	Refreshable *internal.RefreshableConfig

	// Resolver is used to resolve the IP addresses of replacement hosts.
	Resolver agdnet.Resolver

	// ErrColl is used to report errors of replacement-host resolving.
	ErrColl errcoll.Interface

	// CacheTTL is the time to live of the result cache-items.
	//
	//lint:ignore U1000 TODO(a.garipov): Currently unused.  See AGDNS-398.
	CacheTTL time.Duration

	// CacheSize is the number of items in the result cache.
	CacheSize int
}

Config contains configuration for the safe-search filter.

type Filter

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

Filter modifies the results of queries to search-engine addresses and rewrites them to the IP addresses of their safe versions.

func New

func New(c *Config) (f *Filter)

New returns a new safe-search filter. c must not be nil. The initial refresh should be called explicitly if necessary.

func (*Filter) FilterRequest

func (f *Filter) FilterRequest(
	ctx context.Context,
	req *dns.Msg,
	ri *agd.RequestInfo,
) (r internal.Result, err error)

FilterRequest implements the internal.RequestFilter interface for *Filter. It modifies the response if host matches f.

func (*Filter) ID

func (f *Filter) ID() (id agd.FilterListID)

ID implements the internal.RequestFilter interface for *Filter.

func (*Filter) Refresh

func (f *Filter) Refresh(ctx context.Context, acceptStale bool) (err error)

Refresh reloads the rule list data. If acceptStale is true, and the cache file exists, the data is read from there regardless of its staleness.

Jump to

Keyboard shortcuts

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