shadowsocks_pbf

package module
v0.0.0-...-9540a16 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

shadowsocks-pbf

Persistent bloom filter for shadowsocks.

It is mainly with reference to the mechanism of AOF (Append Only File) of redis.

However, there is still the problem of occupying memory. Visit disk-bloom-filter for another solution.

Thanks

Documentation

Index

Constants

View Source
const (
	DefaultSFCapacity = 1e6
	// FalsePositiveRate
	DefaultSFFPR  = 1e-6
	DefaultSFSlot = 10
)

Those suggest value are all set according to https://github.com/shadowsocks/shadowsocks-org/issues/44#issuecomment-281021054 Due to this package contains various internal implementation so const named with DefaultBR prefix

Variables

View Source
var (
	SnapshotIsPerformingError = errors.New("another snapshot is performing")
	DamagedSnapshotError      = errors.New("the snapshot is damaged")
)

Functions

This section is empty.

Types

type AppendFsync

type AppendFsync int
const (
	AppendFsyncAlways AppendFsync = iota
	AppendFsyncEverySec
	AppendFsyncNo
)

type PBF

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

PBF is mainly with reference to the mechanism of AOF (Append Only File) of redis.

func New

func New(path string, fsync AppendFsync, lengthIV uint8, slot int, capacity int, falsePositiveRate float64) (*PBF, error)

func NewFromFile

func NewFromFile(path string, fsync AppendFsync) (*PBF, error)

NewFromFile will try recovering from file

func (*PBF) Add

func (p *PBF) Add(b []byte) (err error)

func (*PBF) Close

func (p *PBF) Close() error

func (*PBF) Snapshot

func (p *PBF) Snapshot() (err error)

Snapshot save current binary value to the file. It is like the AOF rewrite, but the result of rewrite is binary of bloomRing to save more storage and speed up the loading.

func (*PBF) Test

func (p *PBF) Test(b []byte) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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