filter

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 10 Imported by: 0

README

Filter

This is a simple interface to filter based on channel id or (peer) pubkey. Currently just a whitelist of what to report is supported but it is easily extendible to blacklists too.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowAllFilter

type AllowAllFilter struct {
	Filter
}

AllowAllFilter struct

func (*AllowAllFilter) AllowChanID added in v0.0.41

func (f *AllowAllFilter) AllowChanID(id uint64) bool

AllowChanID returns true if short channel ID should be allowed

func (*AllowAllFilter) AllowPubKey

func (f *AllowAllFilter) AllowPubKey(id string) bool

AllowPubKey returns true if pubkey should be allowed

func (*AllowAllFilter) AllowSpecial

func (f *AllowAllFilter) AllowSpecial(private bool) bool

AllowSpecial checks against bitmask and can allow all private or public channels

type FileFilter

type FileFilter struct {
	Filter
	WhitelistFilePath string
	Mutex             sync.Mutex
	DefaultOptions    Options
}

FileFilter struct

func (*FileFilter) AllowChanID added in v0.0.41

func (f *FileFilter) AllowChanID(id uint64) bool

AllowChanID checks short channel id

func (*FileFilter) AllowPubKey

func (f *FileFilter) AllowPubKey(id string) bool

AllowPubKey checks whether pubkey is allowed

func (*FileFilter) AllowSpecial

func (f *FileFilter) AllowSpecial(private bool) bool

AllowSpecial is used to allow all private/public chans

func (*FileFilter) Reload

func (f *FileFilter) Reload() error

Reload from file

type Filter

type Filter struct {
	// Options for the filter
	Options Options
	// contains filtered or unexported fields
}

Filter is the main type

func (*Filter) AllowChanID added in v0.0.41

func (f *Filter) AllowChanID(id uint64) bool

AllowChanID returns true if short channel ID should be allowed

func (*Filter) AllowPubKey

func (f *Filter) AllowPubKey(id string) bool

AllowPubKey returns true if pubkey should be allowed

func (*Filter) AllowSpecial

func (f *Filter) AllowSpecial(private bool) bool

AllowSpecial checks against bitmask and can allow all private or public channels

type FilteringInterface added in v0.0.41

type FilteringInterface interface {
	// AllowPubKey returns true if pubkey should be allowed
	AllowPubKey(id string) bool
	// AllowChanID returns true if short channel ID should be allowed
	AllowChanID(id uint64) bool
	// AllowSpecial checks against bitmask and can allow all private or public channels
	AllowSpecial(private bool) bool
}

FilteringInterface is the interface for all filters

func NewAllowAllFilter

func NewAllowAllFilter() (FilteringInterface, error)

NewAllowAllFilter - creates a filter that allow everything

func NewFilterFromFile

func NewFilterFromFile(ctx context.Context, filePath string, options Options) (FilteringInterface, error)

NewFilterFromFile create new FileFilter

func NewUnitTestFilter

func NewUnitTestFilter() (FilteringInterface, error)

NewUnitTestFilter - creates a filter suitable for unit tests

type Options

type Options uint8

Options bitmask for filter

const (
	// None - no options
	None Options = 1 << iota
	// AllowAllPrivate - allow all private channels
	AllowAllPrivate
	// AllowAllPublic - allow all public channels
	AllowAllPublic
)

type UnitTestFilter

type UnitTestFilter struct {
	Filter
}

UnitTestFilter struct

func (*UnitTestFilter) AddAllowChanID added in v0.0.41

func (u *UnitTestFilter) AddAllowChanID(id uint64)

AddAllowChanID - add channel id to allow list

func (*UnitTestFilter) AddAllowPubKey

func (u *UnitTestFilter) AddAllowPubKey(id string)

AddAllowPubKey - add pubkey to allow list

func (*UnitTestFilter) ChangeOptions

func (u *UnitTestFilter) ChangeOptions(options Options)

ChangeOptions - change options of the filter

Jump to

Keyboard shortcuts

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