http

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteAddr

func RemoteAddr(r *http.Request) (string, error)

RemoteAddr collects possible remote addresses from a request.

Types

type RateLimit

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

func NewRateLimit

func NewRateLimit(ctx context.Context, cfg RateLimitConfig) (*RateLimit, error)

func (*RateLimit) NewRequest

func (r *RateLimit) NewRequest(identifier, ip string) error

NewRequest returns nil if the rate has not been exceeded.

type RateLimitConfig

type RateLimitConfig struct {
	CoolDown encoding.Duration `long:"coolDown" description:"rate-limit duration, e.g. 10s, 1m30s, 24h0m0s"`

	AllowList []string `long:"allowList" description:"a list of ip/subnets, e.g. 10.0.0.0/8, 192.168.0.0/16"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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