clientip

package
v0.0.0-...-a99bcb5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: OSL-3.0 Imports: 2 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

Overview

Package clientip normalises client addresses for rate-limit keys and resolves the client address behind trusted proxies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateLimitKey

func RateLimitKey(sourceIP string) string

RateLimitKey returns the per-IP rate-limit key for a source address: IPv4 unchanged, IPv6 masked to its /64, anything unparsable the shared "invalid" key. /56 and /48 rotation by one client still works; only /64 is collapsed.

func Resolve

func Resolve(remoteAddr, xff string, trustedHops int) string

Resolve returns the client address for a request that crossed trustedHops appending proxies. With n X-Forwarded-For entries it uses entry n-hops; with hops <= 0, fewer entries than hops, or an unparsable or empty entry it falls back to the peer address, so unparsable text is never used as a key. IPv6 stays full-width; use RateLimitKey for the /64 key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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