ipfilter

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

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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/Noah-Labs-Development/krakend-ipfilter": {
            "allow": [
                "192.168.1.1"
            ],
            "deny": [
                "192.168.0.0/16"
            ]
        }
    }
...

Test

make test

Documentation

Index

Constants

View Source
const Namespace = "github_com/Noah-Labs-Development/krakend-ipfilter"

Namespace is ipfilter's config key in extra config

Variables

This section is empty.

Functions

func IpFilterFactory

func IpFilterFactory(ipFilter IPFilter, handlerFunc gin.HandlerFunc, logger logging.Logger) gin.HandlerFunc

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

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) *Config

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

Jump to

Keyboard shortcuts

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