lists

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidListCacheType = fmt.Errorf("not a valid ListCacheType, try [%s]", strings.Join(_ListCacheTypeNames, ", "))

Functions

func ListCacheTypeNames

func ListCacheTypeNames() []string

ListCacheTypeNames returns a list of possible string values of ListCacheType.

Types

type FileDownloader

type FileDownloader interface {
	DownloadFile(ctx context.Context, link string) (io.ReadCloser, error)
}

FileDownloader is able to download some text file

func NewDownloader

func NewDownloader(cfg config.Downloader, transport http.RoundTripper) FileDownloader

type ListCache

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

ListCache generic cache of strings divided in groups

func NewListCache

func NewListCache(ctx context.Context,
	t ListCacheType, cfg config.SourceLoading,
	groupSources map[string][]config.BytesSource, downloader FileDownloader,
) (*ListCache, error)

NewListCache creates new list instance

func (*ListCache) LogConfig

func (b *ListCache) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

func (*ListCache) Match

func (b *ListCache) Match(domain string, groupsToCheck []string) (matches map[string]string)

Match matches passed domain name against cached list entries. Returns a map of matching group -> the rule that matched, or nil/empty when the domain is not in any of the groups.

func (*ListCache) PublishGroupCounts added in v0.32.0

func (b *ListCache) PublishGroupCounts()

PublishGroupCounts re-emits a BlockingCacheGroupChanged event with the current element count for every configured group. The initial counts are emitted while the lists load during construction, before later-constructed subscribers (such as the stats resolver) attach to the bus; re-publishing lets those subscribers pick up the point-in-time counts without waiting for the next list refresh.

func (*ListCache) Refresh

func (b *ListCache) Refresh(ctx context.Context) error

Refresh triggers the refresh of a list

type ListCacheType

type ListCacheType int

ListCacheType represents the type of cached list ENUM( denylist // is a list with blocked domains allowlist // is a list with allowlisted domains / IPs )

const (
	// ListCacheTypeDenylist is a ListCacheType of type Denylist.
	// is a list with blocked domains
	ListCacheTypeDenylist ListCacheType = iota
	// ListCacheTypeAllowlist is a ListCacheType of type Allowlist.
	// is a list with allowlisted domains / IPs
	ListCacheTypeAllowlist
)

func ParseListCacheType

func ParseListCacheType(name string) (ListCacheType, error)

ParseListCacheType attempts to convert a string to a ListCacheType.

func (*ListCacheType) AppendText added in v0.28.0

func (x *ListCacheType) AppendText(b []byte) ([]byte, error)

AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.

Implementations must not retain b, nor mutate any bytes within b[:len(b)].

func (ListCacheType) IsValid

func (x ListCacheType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ListCacheType) MarshalText

func (x ListCacheType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (ListCacheType) String

func (x ListCacheType) String() string

String implements the Stringer interface.

func (*ListCacheType) UnmarshalText

func (x *ListCacheType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Matcher

type Matcher interface {
	// Match matches passed domain name against cached list entries.
	// Returns a map of matching group -> the rule that matched, or nil/empty
	// when the domain is not in any of the groups.
	Match(domain string, groupsToCheck []string) (matches map[string]string)
}

Matcher checks if a domain is in a list

type SourceOpener

type SourceOpener interface {
	fmt.Stringer

	Open(ctx context.Context) (io.ReadCloser, error)
}

func NewSourceOpener

func NewSourceOpener(txtLocInfo string, source config.BytesSource, downloader FileDownloader) (SourceOpener, error)

type TransientError

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

TransientError represents a temporary error like timeout, network errors...

func (*TransientError) Error

func (e *TransientError) Error() string

func (*TransientError) Unwrap

func (e *TransientError) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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