replayfilter

package
v0.0.0-...-b59c172 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: BSD-2-Clause, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package replayfilter implements a generic replay detection filter with a caller specifiable time-to-live. It only detects if a given byte sequence has been seen before based on the SipHash-2-4 digest of the sequence. Collisions are treated as positive matches, though the probability of this happening is negligible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReplayFilter

type ReplayFilter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ReplayFilter is a simple filter designed only to detect if a given byte sequence has been seen before.

func New

func New(ttl time.Duration) (filter *ReplayFilter, err error)

New creates a new ReplayFilter instance.

func (*ReplayFilter) TestAndSet

func (f *ReplayFilter) TestAndSet(now time.Time, buf []byte) bool

TestAndSet queries the filter for a given byte sequence, inserts the sequence, and returns if it was present before the insertion operation.

Jump to

Keyboard shortcuts

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