proxy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxForwardedForHops = 32

MaxForwardedForHops limits the amount of X-Forwarded-For entries inspected per request. The trusted chain is walked from the right, closest to the app.

Variables

This section is empty.

Functions

func ParsePrefixes

func ParsePrefixes(cidrs []string) ([]netip.Prefix, error)

ParsePrefixes parses trusted proxy CIDR strings once at application startup.

func RealIP

func RealIP(r *http.Request, trustedProxies []netip.Prefix) string

RealIP reports the original client IP when the immediate peer is trusted. The RFC 7239 Forwarded header (for= parameters) takes precedence over the legacy X-Forwarded-For and X-Real-IP headers; all chain sources are walked with the same right-to-left trusted-hop semantics.

func RemoteAddrIP

func RemoteAddrIP(remoteAddr string) (addr netip.Addr, fallback string, ok bool)

RemoteAddrIP parses an http.Request RemoteAddr and returns an IP-only string for valid addresses. If RemoteAddr is unparseable, fallback is the trimmed RemoteAddr value and ok is false.

func Scheme

func Scheme(r *http.Request, trustedProxies []netip.Prefix) string

Scheme reports the original client scheme when the immediate peer is trusted. The RFC 7239 Forwarded header takes precedence over the legacy X-Forwarded-* headers.

func Trusted

func Trusted(prefixes []netip.Prefix, addr netip.Addr) bool

Trusted reports whether addr is contained in any trusted proxy prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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