ratelimit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = map[string]Limit{
	"smtp_per_ip":     {Count: 100, Window: time.Hour},
	"smtp_per_user":   {Count: 500, Window: time.Hour},
	"smtp_per_domain": {Count: 1000, Window: time.Hour},
	"auth_per_ip":     {Count: 10, Window: 15 * time.Minute},
	"imap_per_user":   {Count: 1000, Window: time.Hour},
	"api_per_ip":      {Count: 100, Window: time.Hour},
	"api_per_user":    {Count: 1000, Window: time.Hour},
}

Functions

This section is empty.

Types

type Limit

type Limit struct {
	Count  int           // Max requests
	Window time.Duration // Time window
}

type Limiter

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

func NewLimiter

func NewLimiter(repo repository.RateLimitRepository) *Limiter

func (*Limiter) Check

func (l *Limiter) Check(limitType, key string) (bool, error)

func (*Limiter) CheckAuth

func (l *Limiter) CheckAuth(ip string) (bool, error)

func (*Limiter) CheckIP

func (l *Limiter) CheckIP(ip string) (bool, error)

func (*Limiter) CheckUser

func (l *Limiter) CheckUser(userID string) (bool, error)

Jump to

Keyboard shortcuts

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