iplist

package
v7.0.0-...-008fd20 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package iplist 根据 IP 对请求进行过滤

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPLister

type IPLister interface {
	web.Middleware

	// Set 设置名单列表
	//
	// ip IP 地址,可以是具体的 IP 地址,比如 44.44.44.44,
	// 也可以是通配符(以 /* 结尾),比如 2.2/*,表示匹配 2.2.1.1 也匹配 2.22.1.1,
	// 但是并不匹配 ipv6 的相同地址 ::0202:0202。
	// 如果已经存在相同的值,则不会重复添加。
	//
	// NOTE: 传递空值将清空内容。
	Set(ip ...string)

	// List 返回名单列表
	List() []string
}

IPLister 根据客户端的 IP 过滤

func NewBlack

func NewBlack() IPLister

NewWhite 声明黑名单过滤器

所有未在黑名单中的 IP 才允许访问。

func NewWhite

func NewWhite() IPLister

NewWhite 声明白名单过滤器

所有未在白名单中的 IP 都将被禁止访问。

Jump to

Keyboard shortcuts

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