safesearch

package
v0.0.0-...-9998b90 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package safesearch implements safesearch host matching.

Index

Constants

View Source
const (
	LogPrefix    = "safesearch"
	LogKeyClient = "client"
)

Attribute keys and values for logging.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

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

Default is the default safe search filter that uses filtering rules with the dnsrewrite modifier.

func NewDefault

func NewDefault(ctx context.Context, conf *DefaultConfig) (ss *Default, err error)

NewDefault returns an initialized default safe search filter. ctx is used to log the initial refresh.

func (*Default) CheckHost

func (ss *Default) CheckHost(
	ctx context.Context,
	host string,
	qtype rules.RRType,
) (res filtering.Result, err error)

CheckHost implements the filtering.SafeSearch interface for *Default.

func (*Default) Update

func (ss *Default) Update(ctx context.Context, conf filtering.SafeSearchConfig) (err error)

Update implements the filtering.SafeSearch interface for *Default. Update ignores the CustomResolver and Enabled fields.

type DefaultConfig

type DefaultConfig struct {
	// Logger is used for logging the operation of the safe search filter.
	Logger *slog.Logger

	// ClientName is the name of the persistent client associated with the safe
	// search filter, if there is one.
	ClientName string

	// CacheSize is the size of the filter results cache.
	CacheSize uint

	// CacheTTL is the Time to Live duration for cached items.
	CacheTTL time.Duration

	// ServicesConfig contains safe search settings for services.  It must not
	// be nil.
	ServicesConfig filtering.SafeSearchConfig
}

DefaultConfig is the configuration structure for Default.

type Service

type Service string

Service is a enum with service names used as search providers.

const (
	Bing       Service = "bing"
	DuckDuckGo Service = "duckduckgo"
	Ecosia     Service = "ecosia"
	Google     Service = "google"
	Pixabay    Service = "pixabay"
	Yandex     Service = "yandex"
	YouTube    Service = "youtube"
)

Service enum members.

Jump to

Keyboard shortcuts

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