utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP added in v0.2.0

func ClientIP(req *http.Request, trustProxyHeaders bool) string

ClientIP returns the client IP for a request.

When trustProxyHeaders is false (default), only RemoteAddr is used. This is safe when Forq is exposed directly to clients.

When true, the rightmost entry of X-Forwarded-For is used (the IP the proxy adds for the connecting client), falling back to RemoteAddr if the header is absent or malformed. Set FORQ_TRUST_PROXY_HEADERS=true ONLY when Forq is behind a reverse proxy that strips or replaces incoming X-Forwarded-For from clients - otherwise attackers can spoof their IP and bypass throttling. Assumes a single proxy hop; multi-hop deployments should canonicalize the header at the edge proxy before it reaches Forq.

Types

This section is empty.

Jump to

Keyboard shortcuts

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