filters

package
v1.6.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const UpdateInterval = 5 * time.Minute

UpdateInterval is the default interval at which the public list is refected and updated

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockFilter

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

BlockFilter manages updating a deny list and checking for CID inclusion in that list

func NewBlockFilter

func NewBlockFilter() *BlockFilter

func (*BlockFilter) FulfillRequest

func (bf *BlockFilter) FulfillRequest(p peer.ID, c cid.Cid) (bool, error)

FulfillRequest checks if a given CID is in the deny list, per the rules of hashing cids (convert to base32, add "/" to path, then sha256 hash)

func (*BlockFilter) ParseUpdate

func (bf *BlockFilter) ParseUpdate(stream io.Reader) error

ParseUpdate parses and updates the block filter list based on an endpoint response

type ConfigFilter

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

ConfigFilter manages filtering based on a remotely fetched retrieval configuration

func NewConfigFilter

func NewConfigFilter() *ConfigFilter

NewConfigFilter constructs a new peer filter

func (*ConfigFilter) FulfillRequest

func (cf *ConfigFilter) FulfillRequest(p peer.ID, c cid.Cid) (bool, error)

FulfillRequest checks if a given peer is in the allow/deny list and decides whether to fulfill the request

func (*ConfigFilter) ParseUpdate

func (cf *ConfigFilter) ParseUpdate(stream io.Reader) error

ParseUpdate parses and updates the Peer filter list based on an endpoint response

type Fetcher

type Fetcher func(lastFetchTime time.Time) (bool, io.ReadCloser, error)

Fetcher is a function that fetches from a remote source The first return value indicates whether any update has occurred since the last fetch time The second return is a stream of data if an update has occurred The third is any error

func FetcherForHTTPEndpoint

func FetcherForHTTPEndpoint(endpoint string, authHeader string) Fetcher

FetcherForHTTPEndpoint makes an fetcher that reads from an HTTP endpoint

type FilterDefinition

type FilterDefinition struct {
	Fetcher   Fetcher
	Handler   Handler
	CacheFile string
}

type Handler

type Handler interface {
	ParseUpdate(io.Reader) error
	// FulfillRequest returns true if a request should be fulfilled
	// error indicates an error in processing
	FulfillRequest(p peer.ID, c cid.Cid) (bool, error)
}

type MultiFilter

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

func NewMultiFilter

func NewMultiFilter(
	cfgDir string,
	apiFilterEndpoint string,
	apiFilterAuth string,
	BadBitsDenyList []string,
) *MultiFilter

func NewMultiFilterWithConfigs

func NewMultiFilterWithConfigs(cfgDir string, filterDefinitions []FilterDefinition, clock clock.Clock, onTick func()) *MultiFilter

func (*MultiFilter) Close

func (mf *MultiFilter) Close()

Close shuts down asynchronous updating

func (*MultiFilter) FulfillRequest

func (mf *MultiFilter) FulfillRequest(p peer.ID, c cid.Cid) (bool, error)

FulfillRequest returns true if a request should be fulfilled error indicates an error in processing

func (*MultiFilter) Start

func (mf *MultiFilter) Start(ctx context.Context) error

Start initializes asynchronous updates to the filter configs It blocks to confirm at least one synchronous update of each filter

type PeerListType

type PeerListType string

PeerListType is either an allow list or a deny list

const AllowList PeerListType = "allowlist"

AllowList is a peer list where only the specified peers are allowed to serve retrievals

const DenyList PeerListType = "denylist"

DenyList is a peer list where the specified peers cannot serve retrievals, but all others can

Jump to

Keyboard shortcuts

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