ipfilter

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

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.

func (*IPFilter) AllowHTTPContext

func (f *IPFilter) AllowHTTPContext(ctx context.HTTPContext) bool

AllowHTTPContext is the wrapper of Allow for HTTPContext.

type IPFilters

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

IPFilters is the wrapper for multiple IPFilters.

func NewIPFilters added in v1.2.1

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) AllowHTTPContext

func (f *IPFilters) AllowHTTPContext(ctx context.HTTPContext) bool

AllowHTTPContext is the wrapper of Allow for HTTPContext.

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 `yaml:"blockByDefault" jsonschema:"required"`

	AllowIPs []string `yaml:"allowIPs" jsonschema:"omitempty,uniqueItems=true,format=ipcidr-array"`
	BlockIPs []string `yaml:"blockIPs" jsonschema:"omitempty,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