failban

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMiddleware

func CheckMiddleware(next http.Handler) http.Handler

provide a middleware that check if the source IP is banned

func Init

func Init()

we init the localMiddleware

Types

type Middleware

type Middleware struct {
	StrikesMax uint32        `default:"3"`
	Checktick  time.Duration `default:"1m"`
	Timeout    time.Duration `default:"3m"`
	HoldTime   time.Duration `default:"500ms"` // this is the time, we hold a client in line when it is banned
	// contains filtered or unexported fields
}

Define our struct

func (*Middleware) CheckMiddleware

func (mdw *Middleware) CheckMiddleware(next http.Handler) http.Handler

provide a middleware that check if the source IP is banned

func (*Middleware) Init

func (mdw *Middleware) Init()

func (*Middleware) IsBanned

func (mdw *Middleware) IsBanned(req *http.Request) (banned bool)

func (*Middleware) Strike

func (mdw *Middleware) Strike(req *http.Request)

func (*Middleware) TimerSet

func (mdw *Middleware) TimerSet(tick time.Duration, timeout time.Duration)

Jump to

Keyboard shortcuts

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