Documentation
¶
Overview ¶
Package geoip resolves a client IP address to a best-guess ISO country code, for DetectedCountry only (display/discovery convenience — never authoritative for billing; see the localization module's middleware).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudflareHeaderResolver ¶
type CloudflareHeaderResolver struct {
// contains filtered or unexported fields
}
CloudflareHeaderResolver trusts a header injected by Cloudflare's edge (or a compatible upstream proxy) instead of doing its own IP lookup. Only correct to use when the app's traffic genuinely all passes through Cloudflare (or something else that sets and can be trusted to set this header) — otherwise a client can spoof it.
func NewCloudflareHeaderResolver ¶
func NewCloudflareHeaderResolver(headerName string) *CloudflareHeaderResolver
func (*CloudflareHeaderResolver) HeaderName ¶
func (r *CloudflareHeaderResolver) HeaderName() string
HeaderName is the header this resolver reads — callers extract it from the incoming request and pass the value to Lookup as ip (despite the parameter name, this resolver ignores the actual IP and only cares about the pre-resolved header value the caller hands it).
type MaxMindResolver ¶
type MaxMindResolver struct {
// contains filtered or unexported fields
}
MaxMindResolver looks up countries from a self-hosted GeoLite2-Country (or commercial GeoIP2-Country) .mmdb file — no per-request external API call.
func NewMaxMindResolver ¶
func NewMaxMindResolver(path string) (*MaxMindResolver, error)
NewMaxMindResolver opens the .mmdb file at path. The returned resolver owns the file handle; call Close when the host app shuts down.
func (*MaxMindResolver) Close ¶
func (r *MaxMindResolver) Close() error
type NoneResolver ¶
type NoneResolver struct{}
NoneResolver never resolves anything — used when GeoIP detection is disabled (Config.GeoIP.Provider == "none").
type Resolver ¶
Resolver looks up the country an IP address most likely belongs to. ok=false means "no confident answer" (private/unroutable IP, provider disabled, lookup failure, or the DB has no entry) — callers should fall back to the module's configured default rather than treating it as an error.