ipfilter

package
v0.7.23 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseIPRange

func ParseIPRange(startIP, endIP string) ([]netip.Prefix, error)

func ParsePrefix added in v0.7.23

func ParsePrefix(ip string) (pfx netip.Prefix, err error)

func ToPrefixes

func ToPrefixes(start netip.Addr, end netip.Addr) ([]netip.Prefix, error)

func Validate added in v0.7.23

func Validate(ip string) error

func ValidateRange added in v0.7.23

func ValidateRange(startIP, endIP string) error

Types

type IPFilter

type IPFilter struct {
	Whitelist *bart.Table[struct{}]
	Blacklist *bart.Table[struct{}]
}

func New

func New() *IPFilter

func (*IPFilter) AddBlacklist

func (a *IPFilter) AddBlacklist(ips ...string) error

func (*IPFilter) AddWhitelist

func (a *IPFilter) AddWhitelist(ips ...string) error

func (*IPFilter) Allowed

func (f *IPFilter) Allowed(ip string) error

func (*IPFilter) Blocked

func (f *IPFilter) Blocked(ip string) error

func (*IPFilter) IsAllowed

func (a *IPFilter) IsAllowed(realIP string) bool

func (*IPFilter) IsAllowedAddr added in v0.7.22

func (a *IPFilter) IsAllowedAddr(ip netip.Addr) bool

Jump to

Keyboard shortcuts

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