fail2ban

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail2Ban

func Fail2Ban[Req, Res any](p Protector, keyFn func(ctx context.Context, req Req) string) action.Middleware[Req, Res]

Fail2Ban middleware.

Types

type MemoryProtector

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

func (*MemoryProtector) Check

func (m *MemoryProtector) Check(_ context.Context, key string) error

func (*MemoryProtector) RecordFailure

func (m *MemoryProtector) RecordFailure(_ context.Context, key string)

func (*MemoryProtector) RecordSuccess

func (m *MemoryProtector) RecordSuccess(_ context.Context, key string)

type Protector

type Protector interface {
	Check(ctx context.Context, key string) error
	RecordFailure(ctx context.Context, key string)
	RecordSuccess(ctx context.Context, key string)
}

Protector prevents brute-force attacks.

func NewMemoryProtector

func NewMemoryProtector(maxFails int, window, lockout time.Duration) Protector

func NewRedisProtector

func NewRedisProtector(client *redis.Client, prefix string, maxFails int, window, lockout time.Duration) Protector

type RedisProtector

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

func (*RedisProtector) Check

func (r *RedisProtector) Check(ctx context.Context, key string) error

func (*RedisProtector) RecordFailure

func (r *RedisProtector) RecordFailure(ctx context.Context, key string)

func (*RedisProtector) RecordSuccess

func (r *RedisProtector) RecordSuccess(ctx context.Context, key string)

Jump to

Keyboard shortcuts

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