geoip

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxForwardedHeaderBytes = coregeoip.MaxForwardedHeaderBytes
	MaxForwardedHops        = coregeoip.MaxForwardedHops
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(in Input, next http.Handler) http.Handler

Middleware returns the early ingress gate. A nil policy is a structural disabled fast path: no client resolution, lookup, or policy evaluation occurs.

func ResolveClientIP

func ResolveClientIP(r *http.Request, cfg ResolverConfig) (netip.Addr, error)

ResolveClientIP resolves a literal IP without DNS. Forwarding metadata is authoritative only when the immediate direct peer is trusted.

Types

type Input

type Input struct {
	Policy   *coregeoip.Policy
	Lookup   coregeoip.CountryLookup
	Resolver ResolverConfig
	Observer Observer
}

Input is the generation-scoped, non-owning GeoIP gate projection.

type Observer

type Observer interface {
	Decision(reason coregeoip.Reason, allow bool)
}

Observer receives finite-label decision outcomes without request-controlled data.

type ResolverConfig

type ResolverConfig struct {
	Source         Source
	TrustedProxies []netip.Prefix
}

ResolverConfig is immutable input for one request-plane generation.

type Source

type Source string

Source selects the authoritative client address source.

const (
	SourceDirect        Source = "direct"
	SourceXForwardedFor Source = "x_forwarded_for"
	SourceForwarded     Source = "forwarded"
)

Jump to

Keyboard shortcuts

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