Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) ASN(ip net.IP) (*geoip2.ASN, error)
- func (c *Client) City(ip net.IP) (*geoip2.City, error)
- func (c *Client) Close()
- func (c *Client) Country(ip net.IP) (*geoip2.Country, error)
- func (c *Client) DownloadAllDB() error
- func (c *Client) IP2ASN(ipStr string) (IPASN, error)
- func (c *Client) IP2City(ipStr string) (IPCity, error)
- func (c *Client) IP2Country(ipStr string) (IPCountry, error)
- func (c *Client) IP2Geo(ipStr string) (GeoIP, error)
- func (c *Client) Load() error
- func (c *Client) RunDBDownloadJob(ctx context.Context)
- type DBType
- type GeoIP
- type IPASN
- type IPCity
- type IPCountry
Constants ¶
View Source
const ( MaxMindDownloadPathQuery = "/app/geoip_download?edition_id=%s&license_key=%s&suffix=%s" DBArchiveDownloadSuffix = "tar.gz" DBSHA256FileDownloadSuffix = "tar.gz.sha256" DBSuffix = "mmdb" )
Variables ¶
View Source
var ( MaxMindHost = "https://download.maxmind.com" MaxMindDownloadURL = fmt.Sprintf("%s%s", MaxMindHost, MaxMindDownloadPathQuery) )
View Source
var ( // ErrCountryDBNotLoaded is returned when the country database is not loaded. ErrCountryDBNotLoaded = errors.New("country database not loaded") // ErrCityDBNotLoaded is returned when the city database is not loaded. ErrCityDBNotLoaded = errors.New("city database not loaded") // ErrASNDBNotLoaded is returned when the ASN database is not loaded. ErrASNDBNotLoaded = errors.New("ASN database not loaded") // ErrLicenseKeyRequired is returned when the MaxMind license key is missing. ErrLicenseKeyRequired = errors.New("WAYPOINT_MAXMIND_LICENSE_KEY is required") // ErrChecksumMismatch is returned when the downloaded file checksum does not match. ErrChecksumMismatch = errors.New("checksum mismatch") // ErrEmptySHA256File is returned when the SHA256 file is empty. ErrEmptySHA256File = errors.New("empty SHA256 file") // ErrInvalidSHA256File is returned when the SHA256 file format is invalid. ErrInvalidSHA256File = errors.New("invalid SHA256 file format") // ErrDBDownloadFailed is returned when downloading databases fails and no local copies exist. ErrDBDownloadFailed = errors.New("failed to download databases and no existing files found") // ErrDBOpenFailed is returned when opening a database file fails. ErrDBOpenFailed = errors.New("failed to open database") // ErrInvalidIP is returned when an invalid IP address is provided. ErrInvalidIP = errors.New("invalid IP address") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles MaxMind database operations and lookups.
func NewClient ¶
func NewClient(cfg *config.MaxMindConfig, dataDir string) *Client
NewClient creates a new MaxMind client.
func (*Client) DownloadAllDB ¶
DownloadAllDB downloads all configured databases.
func (*Client) IP2Country ¶
IP2Country looks up country information for an IP address.
func (*Client) RunDBDownloadJob ¶
RunDBDownloadJob starts the background job for downloading databases.
type IPASN ¶
type IPASN struct {
IP string `json:"ip"`
ASN uint `json:"asn"`
Organization string `json:"organization"`
}
IPASN represents ASN information for an IP.
type IPCity ¶
type IPCity struct {
City string `json:"city"`
IPCountry
Timezone string `json:"timezone"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}
IPCity represents city information for an IP.
type IPCountry ¶
type IPCountry struct {
IP string `json:"ip"`
Country string `json:"country"`
Continent string `json:"continent"`
ISOCountryCode string `json:"iso_country_code"`
ISOContinentCode string `json:"iso_continent_code"`
IsAnonymousProxy bool `json:"is_anonymous_proxy"`
IsSatelliteProvider bool `json:"is_satellite_provider"`
}
IPCountry represents country information for an IP.
Click to show internal directories.
Click to hide internal directories.