blocker

package
v0.0.0-...-78dab50 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blocker

func Blocker() gin.HandlerFunc

Types

type IPList

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

func New

func New(initSorted []Range) *IPList

Create a new IP list. The given ranges must already sorted by the lower bound IP in each range. Behaviour is undefined for lists of overlapping ranges.

func (*IPList) Lookup

func (ipl *IPList) Lookup(ip net.IP) (r Range, ok bool)

Return the range the given IP is in. ok if false if no range is found.

func (*IPList) NumRanges

func (ipl *IPList) NumRanges() int

type Range

type Range struct {
	First, Last net.IP
	Description string
}

func (Range) String

func (r Range) String() string

type Ranger

type Ranger interface {
	Lookup(net.IP) (r Range, ok bool)
	NumRanges() int
}

Jump to

Keyboard shortcuts

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