ratelimit

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ratelimit limits failed login attempts per client IP.

Index

Constants

View Source
const (
	DefaultLimit  = 10
	DefaultWindow = time.Minute
)

DefaultLimit and DefaultWindow cap login attempts per client IP.

Variables

This section is empty.

Functions

func Middleware

func Middleware(cfg Config) func(http.Handler) http.Handler

Middleware returns middleware that limits failed login attempts per client IP.

func ParseTrustedProxies

func ParseTrustedProxies(raw string) ([]string, error)

ParseTrustedProxies parses a comma-separated list into trusted-proxy CIDR ranges.

Types

type Config

type Config struct {
	// Limit caps failed attempts per client IP per Window. Zero applies DefaultLimit.
	Limit int
	// Window is the counting window. Zero applies DefaultWindow.
	Window time.Duration
	// TrustedProxies lists the CIDR ranges of reverse proxies permitted to
	// set X-Forwarded-For.
	TrustedProxies []string
}

Config parameterizes the limiter.

Jump to

Keyboard shortcuts

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