access

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

package for access control

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIP = errors.New("IP address is not valid")
)

Functions

func GetClientIP

func GetClientIP(req *http.Request) (remoteIP string)

GetClientIP return remote IP address from request

func IsIntranetIP

func IsIntranetIP(ip net.IP) bool

IsIntranetIP reports whether ip is intranet ip.

Invalid ip return false.

func IsIntranetIPAddress

func IsIntranetIPAddress(ipStr string) bool

IsIntranetIP reports whether ip is intranet ip.

Invalid ip return false.

func IsPublicIP

func IsPublicIP(ip net.IP) bool

IsPublicIP reports whether ip is public network address.

Invalid ip return false.

func IsPublicIPAddress

func IsPublicIPAddress(ipStr string) bool

IsPublicIP reports whether ip is public network address.

Invalid ip return false.

Types

type IPList

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

func NewIPList

func NewIPList(vals ...string) *IPList

Value格式: 111.10.11.3, 111.10.11.0/24

func NewIPWhitelist

func NewIPWhitelist(vals ...interface{}) *IPList

NewIPWhitelist("192.168.1.1", "192.168.1.0/24,192.168.1.3", []string{"10.0.0.1"}, []interface{}{"127.0.0.1"})

func (*IPList) Contains

func (l *IPList) Contains(ip string) bool

Jump to

Keyboard shortcuts

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