antispam

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Antispammer

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

Antispammer makes a decision on the need to parse the input log. It can be useful when any application writes logs at speed faster than File.d can read it.

Anti-spammer supports exceptions for cases where you need to guarantee delivery of an important events.

func NewAntispammer

func NewAntispammer(o Options) *Antispammer

func (*Antispammer) Dump

func (a *Antispammer) Dump() string

func (*Antispammer) IsSpam

func (a *Antispammer) IsSpam(id uint64, name string, isNewSource bool, event []byte) bool

func (*Antispammer) Maintenance

func (a *Antispammer) Maintenance()

type Cond

type Cond byte
const (
	CondAnd Cond = iota
	CondOr
)

func (*Cond) UnmarshalJSON

func (c *Cond) UnmarshalJSON(i []byte) error

type Exception

type Exception struct {
	Name  string `json:"name"`
	Cond  Cond   `json:"cond"`
	Rules []Rule `json:"rules"`
}

func (*Exception) Match

func (e *Exception) Match(data []byte) bool

type Mode

type Mode byte
const (
	ModePrefix Mode = iota
	ModeContains
	ModeSuffix
)

func (*Mode) UnmarshalJSON

func (m *Mode) UnmarshalJSON(i []byte) error

type Options

type Options struct {
	MaintenanceInterval time.Duration
	Threshold           int
	UnbanIterations     int
	Exceptions          []Exception

	Logger            *zap.Logger
	MetricsController *metric.Ctl
}

type Rule

type Rule struct {
	// Values to match at least one value.
	Values []string `json:"values"`
	Mode   Mode     `json:"mode"`
	// CaseInsensitive is the truth then Match results in a lowercase search value.
	// Not available fo the ModeContains because performance issues may arise.
	CaseInsensitive bool `json:"case_insensitive"`
	Invert          bool `json:"invert"`
}

func NewRule

func NewRule(values []string, mode Mode, caseInsensitive bool) Rule

func (*Rule) Match

func (e *Rule) Match(raw []byte) bool

Jump to

Keyboard shortcuts

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