xff: github.com/sebest/xff Index | Files

package xff

import "github.com/sebest/xff"

Index

Package Files

xff.go

func GetRemoteAddr Uses

func GetRemoteAddr(r *http.Request) string

GetRemoteAddr parses the given request, resolves the X-Forwarded-For header and returns the resolved remote address.

func GetRemoteAddrIfAllowed Uses

func GetRemoteAddrIfAllowed(r *http.Request, allowed func(sip string) bool) string

GetRemoteAddrIfAllowed parses the given request, resolves the X-Forwarded-For header and returns the resolved remote address if allowed.

func IsPublicIP Uses

func IsPublicIP(ip net.IP) bool

IsPublicIP returns true if the given IP can be routed on the Internet.

func Parse Uses

func Parse(ipList string) string

Parse parses the value of the X-Forwarded-For Header and returns the IP address.

type Options Uses

type Options struct {
    // AllowedSubnets is a list of Subnets from which we will accept the
    // X-Forwarded-For header.
    // If this list is empty we will accept every Subnets (default).
    AllowedSubnets []string
    // Debugging flag adds additional output to debug server side XFF issues.
    Debug bool
}

Options is a configuration container to setup the XFF middleware.

type XFF Uses

type XFF struct {
    // Debug logger
    Log *log.Logger
    // contains filtered or unexported fields
}

XFF http handler

func Default Uses

func Default() (*XFF, error)

Default creates a new XFF handler with default options.

func New Uses

func New(options Options) (*XFF, error)

New creates a new XFF handler with the provided options.

func (*XFF) Handler Uses

func (xff *XFF) Handler(h http.Handler) http.Handler

Handler updates RemoteAdd from X-Fowarded-For Headers.

func (*XFF) HandlerFunc Uses

func (xff *XFF) HandlerFunc(w http.ResponseWriter, r *http.Request)

HandlerFunc provides Martini compatible handler

func (*XFF) ServeHTTP Uses

func (xff *XFF) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Negroni compatible interface

Package xff imports 5 packages (graph) and is imported by 45 packages. Updated 2019-08-12. Refresh now. Tools for package owners.