antispam

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Antispam

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

Antispam is a antispam instance.

func New

func New(c *Config, l func(bucket, dir string) (model.DirRateConfig, bool)) (s *Antispam)

New new a antispam service.

func (*Antispam) Handler

func (s *Antispam) Handler() bm.HandlerFunc

Handler is antispam handle.

func (*Antispam) NativeRate

func (s *Antispam) NativeRate(c *bm.Context, path string, mid interface{}) (err error)

NativeRate limit user + path second level

func (*Antispam) Rate

func (s *Antispam) Rate(c *bm.Context) (err error)

Rate antispam by user + bucket + dir.

func (*Antispam) ServeHTTP

func (s *Antispam) ServeHTTP(ctx *bm.Context)

func (*Antispam) Total

func (s *Antispam) Total(c *bm.Context, hour, count int) (err error)

Total antispam by user + path hour level

type Config

type Config struct {
	On     bool // switch on/off
	Second int  // every N second allow N requests.
	N      int  // one unit allow N requests.
	Hour   int  // every N hour allow M requests.
	M      int  // one winodw allow M requests.

	Redis *redis.Config
}

Config antispam config. On bool // switch on/off Second int // every N second allow N requests. N int // one unit allow N requests. Hour int // every N hour allow M requests. M int // one winodw allow M requests.

Jump to

Keyboard shortcuts

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