ip

package
v7.0.0-...-1c7ecba Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientIP

func GetClientIP(p ipapi.RealClientIPParser, req *http.Request) (net.IP, error)

GetClientIP obtains the perceived end-user IP address from headers if p != nil else from req.RemoteAddr.

func GetClientString

func GetClientString(p ipapi.RealClientIPParser, req *http.Request, full bool) (s string)

GetClientString obtains the human readable string of the remote IP and optionally the real client IP if available

func GetRealClientIPParser

func GetRealClientIPParser(headerKey string) (ipapi.RealClientIPParser, error)

func ParseIPNet

func ParseIPNet(s string) *net.IPNet

Types

type NetSet

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

Fast lookup table for intersection of a single IP address within a collection of CIDR networks.

Supports 4-byte (IPv4) and 16-byte (IPv6) networks.

Provides O(1) best-case, O(log(n)) worst-case performance. In practice netmasks included will generally only be of standard lengths: - /8, /16, /24, and /32 for IPv4 - /64 and /128 for IPv6. As a result, typical lookup times will lean closer to best-case rather than worst-case even when most of the internet is included.

func NewNetSet

func NewNetSet() *NetSet

Create a new NetSet with all of the provided networks.

func (*NetSet) AddIPNet

func (w *NetSet) AddIPNet(ipNet net.IPNet)

Add an CIDR network to the set.

func (*NetSet) Has

func (w *NetSet) Has(ip net.IP) bool

Check if `ip` is in the set, true if within the set otherwise false.

Jump to

Keyboard shortcuts

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