ipfilter

package module
v0.0.0-...-ea25945 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: MIT Imports: 4 Imported by: 0

README

krakend-ipfilter

Test Lint


IP filter middleware for KrakenD(lura) framework, base on cidranger

Example

Deny request from 192.168.0.0/16 but allow 192.168.1.1:

...
    "extra_config": {
        "github_com/xiachufang/krakend-ipfilter": {
            "allow": [
                "192.168.1.1"
            ],
            "deny": [
                "192.168.0.0/16"
            ]
        }
    }
...

Test

make test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CIDRFilter

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

CIDRFilter is an ip filter base on cidranger

func (*CIDRFilter) Allow

func (f *CIDRFilter) Allow(ip string) bool

Allow implement IPFilter.Allow

func (*CIDRFilter) Deny

func (f *CIDRFilter) Deny(ip string) bool

Deny implement IPFilter.Deny

type Config

type Config struct {
	Deny  []string
	Allow []string
}

Config is config of ipfilter

type IPFilter

type IPFilter interface {
	Allow(ip string) bool
	Deny(ip string) bool
}

IPFilter is a interface for allow or deny an ip

func NewIPFilter

func NewIPFilter(cfg Config) IPFilter

NewIPFilter create a cidranger base ip filter

type NoopFilter

type NoopFilter struct{}

NoopFilter noop, allow always, never deny

func (*NoopFilter) Allow

func (noop *NoopFilter) Allow(_ string) bool

Allow implement IPFilter.Allow

func (*NoopFilter) Deny

func (noop *NoopFilter) Deny(_ string) bool

Deny implement IPFilter.Deny

Directories

Path Synopsis
engine
gin

Jump to

Keyboard shortcuts

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