ipfilter

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package ipfilter provides IPFilter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPFilter

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

IPFilter is the IP filter.

func New

func New(spec *Spec) *IPFilter

New creates an IPFilter.

func (*IPFilter) Allow

func (f *IPFilter) Allow(ipstr string) bool

Allow return if IPFilter allows the incoming ip.

type IPFilters

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

IPFilters is the wrapper for multiple IPFilters.

func NewIPFilterChain

func NewIPFilterChain(parentIPFilters *IPFilters, childSpec *Spec) *IPFilters

NewIPFilterChain returns nil if the number of final filters is zero.

func NewIPFilters

func NewIPFilters(filters ...*IPFilter) *IPFilters

NewIPFilters creates an IPFilters

func (*IPFilters) Allow

func (f *IPFilters) Allow(ipstr string) bool

Allow return if IPFilters allows the incoming ip.

func (*IPFilters) Append

func (f *IPFilters) Append(filter *IPFilter)

Append appends an IPFilter.

func (*IPFilters) Filters

func (f *IPFilters) Filters() []*IPFilter

Filters returns internal IPFilters.

type Spec

type Spec struct {
	BlockByDefault bool `json:"blockByDefault,omitempty"`

	AllowIPs []string `json:"allowIPs,omitempty" jsonschema:"uniqueItems=true,format=ipcidr-array"`
	BlockIPs []string `json:"blockIPs,omitempty" jsonschema:"uniqueItems=true,format=ipcidr-array"`
}

Spec describes IPFilter.

Jump to

Keyboard shortcuts

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