geoip

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package geoip is the GeoIP country-lookup engine: a local MaxMind GeoLite2 (.mmdb) reader with an in-memory IP→country cache. It performs no DNS resolution and no SSRF/private-range filtering — callers resolve a host to a public net.IP first (see resolveHost in package main, which owns the shared SSRF check) and then call LookupByIP. This keeps the engine a true leaf with no dependency on the rest of Culvert (extracted under ADR-0002, option F).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled reports whether a GeoIP database is loaded.

func InitGeoDB

func InitGeoDB(path string) error

InitGeoDB opens the GeoLite2-Country .mmdb file. Call once at startup. Subsequent calls replace the open reader atomically.

func LookupByIP

func LookupByIP(ip net.IP) (code, name string)

LookupByIP returns the ISO country code and full name for an already-resolved public IP. Returns ("", "") when GeoIP is disabled, the IP is nil, or the lookup fails. Host resolution + SSRF filtering is the caller's responsibility.

func LookupCachedByIP

func LookupCachedByIP(ip net.IP) (code string, ok bool)

LookupCachedByIP returns the country code only if already cached; it never triggers a new database lookup. Returns ("", false) on a cache miss or a nil IP.

Types

This section is empty.

Jump to

Keyboard shortcuts

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