sourcelimiter

package
v0.1.0-rc.27 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sourcelimiter limits new visitor connections by source IP address.

Index

Constants

View Source
const (
	DefaultRate           = 50
	DefaultBurst          = 200
	DefaultMaxEntries     = 8192
	DefaultIdleExpiration = 10 * time.Minute
	DefaultShards         = 64
)

Variables

This section is empty.

Functions

func Normalize

func Normalize(source netip.Addr) (netip.Addr, bool)

Normalize maps IPv4-mapped addresses to IPv4 and groups IPv6 sources by /64.

Types

type Config

type Config struct {
	Rate             float64
	Burst            int
	MaxEntries       int
	IdleExpiration   time.Duration
	Shards           int
	Now              func() time.Time
	OnEntriesChanged func(int)
}

type Limiter

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

func New

func New(config Config) (*Limiter, error)

func (*Limiter) Allow

func (l *Limiter) Allow(source netip.Addr) bool

func (*Limiter) Entries

func (l *Limiter) Entries() int

Jump to

Keyboard shortcuts

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