iptable

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//子网掩码 默认"255, 255, 255, 0"
	InterMask net.IPMask = net.IPv4Mask(255, 255, 255, 0)
	//默认网关 默认"127, 0, 0, 0"
	InterIPNet      net.IP = net.IPv4(192, 168, 0, 0)
	InterExternalIp        = net.IPv4(192, 168, 0, 0)

	//是否检测ip的安全性(不对外的http服务,可以不用检测)
	CHECK_IPTRUSTED = true
)

Functions

func AddIP

func AddIP(ipmatch string, on bool)

AddIP 添加ip过滤模板 on=true 表示白名单,off表示黑名单

func AddIPs

func AddIPs(ipmatchs map[string]bool)

AddIPs 添加ip过滤模板 on=true 表示白名单,off表示黑名单

func AddIpFilter

func AddIpFilter(ipmatch string, whiteIp bool)

AddIpFilter 添加ip过滤器模板

func DeleteIPs

func DeleteIPs(ipmatchs []string)

DeleteIPs 删除ip名单模板过滤器

func GetBlackList

func GetBlackList() []string

GetBlackList 获取所有的黑名单过滤器模板

func GetLocalExternalIp

func GetLocalExternalIp() (ip string)

GetLocalExternalIp 获取本地外网地址

func GetLocalInternalIp

func GetLocalInternalIp() (ip string)

GetLocalInternalIp 获取本地内网地址

func GetRemoteAddrIP

func GetRemoteAddrIP(remoteAddr string) string

GetRemoteAddrIP 获取连接的的ip地址(eg:192.168.1.2:1234 -->192.168.1.2)

func GetRemoteIP

func GetRemoteIP(con net.Conn) net.IP

GetRemoteIP 获取连接的远程ip信息

func GetWhiteList

func GetWhiteList() []string

GetWhiteList 获取所有的白名单过滤器模板

func IsBlackIp

func IsBlackIp(ipStr string) bool

IsBlackIp 是否在黑名单中(只关系黑名单是否存在)

func IsTrustedIP

func IsTrustedIP(ipStr string) bool

IsTrustedIP 检查ip是否可信任(没在黑名单且在白名单)

func IsTrustedIP1

func IsTrustedIP1(ipStr string) bool

IsTrustedIP1 检查ip是否可信任

func IsWhiteIp

func IsWhiteIp(ipStr string) bool

IsWhiteIp 是否在白名单中(没在黑名单且在白名单)

func LoadIpTable

func LoadIpTable(configurl string)

func ParseFilterIp

func ParseFilterIp(ipmatch string) net.IP

ParseFilterIp 获取匹配ip模板

func PrintIpFilte

func PrintIpFilte()

PrintIpFilte 打印ip过滤表

func RequestIP

func RequestIP(r *http.Request) string

RequestIP returns the string form of the original requester's IP address for the given request, taking into account X-Forwarded-For if applicable. If the request was from a loopback address, then we will take the first non-loopback X-Forwarded-For address. This is under the assumption that your golang server is running behind a reverse proxy.

Types

This section is empty.

Jump to

Keyboard shortcuts

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