filter

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 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
}

func (*AllowAllFilter) AllowChanId

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

func (*AllowAllFilter) AllowPubKey

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

func (*AllowAllFilter) AllowSpecial

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

type FileFilter

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

func (*FileFilter) AllowChanId

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

func (*FileFilter) AllowPubKey

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

func (*FileFilter) AllowSpecial

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

func (*FileFilter) Reload

func (f *FileFilter) Reload() error

type Filter

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

func (*Filter) AllowChanId

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

func (*Filter) AllowPubKey

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

func (*Filter) AllowSpecial

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

type FilterInterface

type FilterInterface interface {
	AllowPubKey(id string) bool
	AllowChanId(id uint64) bool
	AllowSpecial(private bool) bool
}

func NewAllowAllFilter

func NewAllowAllFilter() (FilterInterface, error)

func NewFilterFromFile

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

func NewUnitTestFilter

func NewUnitTestFilter() (FilterInterface, error)

type Options

type Options uint8
const (
	None Options = 1 << iota
	AllowAllPrivate
	AllowAllPublic
)

type UnitTestFilter

type UnitTestFilter struct {
	Filter
}

func (*UnitTestFilter) AddAllowChanId

func (u *UnitTestFilter) AddAllowChanId(id uint64)

func (*UnitTestFilter) AddAllowPubKey

func (u *UnitTestFilter) AddAllowPubKey(id string)

func (*UnitTestFilter) ChangeOptions

func (f *UnitTestFilter) ChangeOptions(options Options)

Jump to

Keyboard shortcuts

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