ipaccess

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIPAccessFactory

func CreateIPAccessFactory(confMap map[string]interface{}) (api.StreamFilterChainFactory, error)

func StructToMap added in v1.1.0

func StructToMap(obj interface{}) (newMap map[string]interface{}, err error)

StructToMap Converts a struct to a map while maintaining the json alias as keys

Types

type Conf

type Conf struct {
	DefaultAction string         `json:"default_action"`
	Header        string         `json:"header"`
	Ips           []*IpAndAction `json:"ips"`
}

type IPAccess

type IPAccess interface {
	IsAllow(ip string) (bool, error)
	IsDenyAction() bool
}

IPAccess check if ip allows access

type IPAccessFactory

type IPAccessFactory struct {
	Conf         *Conf
	AllowAll     bool
	IpAccessList []IPAccess
}

func (*IPAccessFactory) CreateFilterChain

func (i *IPAccessFactory) CreateFilterChain(ctx context.Context, callbacks api.StreamFilterChainFactoryCallbacks)

type IPAccessFilter

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

func NewIPAccessFilter

func NewIPAccessFilter(access []IPAccess, header string, allowAll bool) *IPAccessFilter

func (*IPAccessFilter) OnDestroy

func (f *IPAccessFilter) OnDestroy()

func (*IPAccessFilter) OnReceive

func (f *IPAccessFilter) OnReceive(ctx context.Context, headers api.HeaderMap, buf buffer.IoBuffer, trailers api.HeaderMap) api.StreamFilterStatus

func (*IPAccessFilter) SetReceiveFilterHandler

func (f *IPAccessFilter) SetReceiveFilterHandler(handler api.StreamReceiverFilterHandler)

type IPAllowlist

type IPAllowlist struct {
	*IpList
}

IPAllowlist check whether the ip can be accessed

func (*IPAllowlist) IsAllow

func (i *IPAllowlist) IsAllow(addr string) (bool, error)

IsAllow checks if provided request is allow by the ipaccess.

func (*IPAllowlist) IsDenyAction

func (i *IPAllowlist) IsDenyAction() bool

type IPBlocklist

type IPBlocklist struct {
	*IpList
}

IPBlocklist check if ip is forbidden to access

func (*IPBlocklist) IsAllow

func (i *IPBlocklist) IsAllow(addr string) (bool, error)

func (*IPBlocklist) IsDenyAction

func (i *IPBlocklist) IsDenyAction() bool

type IpAndAction

type IpAndAction struct {
	Action string   `json:"action"`
	Addrs  []string `json:"addrs"`
}

type IpList

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

func NewIpList

func NewIpList(addrs []string) (*IpList, error)

func (*IpList) Exist

func (i *IpList) Exist(addr string) (bool, error)

Exist checks if provided address is in the trusted IPs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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