ip

package
v2.0.0-alpha2+incompat... Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

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

Checker allows to check that addresses are in a trusted IPs

func NewChecker

func NewChecker(trustedIPs []string) (*Checker, error)

NewChecker builds a new Checker given a list of CIDR-Strings to trusted IPs

func (*Checker) Contains

func (ip *Checker) Contains(addr string) (bool, error)

Contains checks if provided address is in the trusted IPs

func (*Checker) ContainsIP

func (ip *Checker) ContainsIP(addr net.IP) bool

ContainsIP checks if provided address is in the trusted IPs

func (*Checker) IsAuthorized

func (ip *Checker) IsAuthorized(addr string) error

IsAuthorized checks if provided request is authorized by the trusted IPs

type CheckerStrategy

type CheckerStrategy struct {
	Checker *Checker
}

CheckerStrategy a strategy based on an IP Checker allows to check that addresses are in a trusted IPs

func (*CheckerStrategy) GetIP

func (s *CheckerStrategy) GetIP(req *http.Request) string

GetIP return the selected IP

type DepthStrategy

type DepthStrategy struct {
	Depth int
}

DepthStrategy a strategy based on the depth inside the X-Forwarded-For from right to left

func (*DepthStrategy) GetIP

func (s *DepthStrategy) GetIP(req *http.Request) string

GetIP return the selected IP

type RemoteAddrStrategy

type RemoteAddrStrategy struct{}

RemoteAddrStrategy a strategy that always return the remote address

func (*RemoteAddrStrategy) GetIP

func (s *RemoteAddrStrategy) GetIP(req *http.Request) string

GetIP return the selected IP

type Strategy

type Strategy interface {
	GetIP(req *http.Request) string
}

Strategy a strategy for IP selection

Jump to

Keyboard shortcuts

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