ipfilter

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: AGPL-3.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStartAndEndIPMismatchType = errors.New(`inconsistency between start and end ip types`)
	ErrParseIPAddress            = errors.New(`failed to parse ip`)
	ErrParseStartIPAddress       = errors.New(`failed to parse ip`)
	ErrParseEndIPAddress         = errors.New(`failed to parse ip`)
)

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

func ValidateRows added in v0.7.24

func ValidateRows(ctx echo.Context, iplist string) error

Types

type Factory added in v0.7.24

type Factory[UK com.Number, GK com.Number] struct {
	// contains filtered or unexported fields
}

func NewFactory added in v0.7.24

func NewFactory[UK com.Number, GK com.Number]() *Factory[UK, GK]

func (*Factory[UK, GK]) DeleteGroup added in v0.7.26

func (f *Factory[UK, GK]) DeleteGroup(groupID GK) *Factory[UK, GK]

func (*Factory[UK, GK]) DeleteUser added in v0.7.26

func (f *Factory[UK, GK]) DeleteUser(userID UK) *Factory[UK, GK]

func (*Factory[UK, GK]) IsAllowed added in v0.7.24

func (f *Factory[UK, GK]) IsAllowed(ctx echo.Context, userID UK, groupID GK, ipBlacklist string, ipWhitelist string, ip netip.Addr) bool

func (*Factory[UK, GK]) SetGroupGetter added in v0.7.24

func (f *Factory[UK, GK]) SetGroupGetter(fn func(ctx echo.Context, groupID GK) (ipBlacklist string, ipWhitelist string, err error)) *Factory[UK, GK]

type IPFilter

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

func New

func New() *IPFilter

func NewWithIP added in v0.7.24

func NewWithIP(ipBlacklist, ipWhitelist string) *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 (a *IPFilter) Allowed(ip string) error

func (*IPFilter) Blocked

func (a *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

func (*IPFilter) SetDisallow added in v0.8.2

func (a *IPFilter) SetDisallow(dfl bool) *IPFilter

Jump to

Keyboard shortcuts

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