ip

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(req *http.Request) string

func ClientPublicIP

func ClientPublicIP(req *http.Request) string

func ContentType

func ContentType(req *http.Request) string

ContentType returns the Content-Type header of the request.

func HasLocalIP

func HasLocalIP(ip net.IP) bool

func HasLocalIPAddr

func HasLocalIPAddr(ip string) bool

func IsWebsocket

func IsWebsocket(req *http.Request) bool

func LongToIP

func LongToIP(i uint) (net.IP, error)

func LongToIPString

func LongToIPString(i uint) (string, error)

func RemoteIP

func RemoteIP(req *http.Request) string

func StringToLong

func StringToLong(ip string) (uint, error)

func ToLong

func ToLong(ip net.IP) (uint, error)

Types

type Filter added in v1.2.12

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

func New added in v1.2.12

func New(opts Options) *Filter

New constructs IPFilter instance without downloading DB.

func (*Filter) AllowIP added in v1.2.12

func (f *Filter) AllowIP(ip string) bool

func (*Filter) Allowed added in v1.2.12

func (f *Filter) Allowed(ipstr string) bool

Allowed returns if a given IP can pass through the filter

func (*Filter) BlockIP added in v1.2.12

func (f *Filter) BlockIP(ip string) bool

func (*Filter) Blocked added in v1.2.12

func (f *Filter) Blocked(ip string) bool

Blocked returns if a given IP can NOT pass through the filter

func (*Filter) NetAllowed added in v1.2.12

func (f *Filter) NetAllowed(ip net.IP) bool

NetAllowed returns if a given net.IP can pass through the filter

func (*Filter) NetBlocked added in v1.2.12

func (f *Filter) NetBlocked(ip net.IP) bool

NetBlocked returns if a given net.IP can NOT pass through the filter

func (*Filter) ToggleDefault added in v1.2.12

func (f *Filter) ToggleDefault(allowed bool)

ToggleDefault alters the default setting

func (*Filter) ToggleIP added in v1.2.12

func (f *Filter) ToggleIP(str string, allowed bool) bool

type Options added in v1.2.12

type Options struct {
	//AllowedIPs allowed IPs
	AllowedIPs []string
	//BlockedIPs blocked IPs
	BlockedIPs []string

	//block by default (defaults to allow)
	BlockByDefault bool
}

Jump to

Keyboard shortcuts

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