freebie

package
v0.0.0-...-56940a3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Count

type Count uint16

type DB

type DB interface {
	CanPass(*http.Request, net.IP) (bool, error)

	TallyFreebie(*http.Request, net.IP) (bool, error)
}

DB is the main interface of the package freebie. It represents a store that keeps track of how many free requests a certain IP address can make to a certain resource.

func NewMemIPMaskStore

func NewMemIPMaskStore(numFreebies Count) DB

NewMemIPMaskStore creates a new in-memory freebie store that masks the last byte of an IP address to keep track of free requests. The last byte of the address is discarded for the mapping to reduce risk of abuse by users that have a whole range of IPs at their disposal.

Jump to

Keyboard shortcuts

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