Documentation
¶
Index ¶
- Constants
- type Config
- type Country
- type Lookup
- func (l *Lookup) Close()
- func (l *Lookup) GetCountry(code string) *Country
- func (l *Lookup) IsAllowed(ipStr string, allowedCountries []string) bool
- func (l *Lookup) IsBlocked(ipStr string, blockedCountries []string) bool
- func (l *Lookup) IsLoaded() bool
- func (l *Lookup) LastUpdate() time.Time
- func (l *Lookup) LoadDatabase(path string) error
- func (l *Lookup) LoadDatabases() error
- func (l *Lookup) Lookup(ipStr string) *Result
- func (l *Lookup) UpdateDatabases() error
- type Result
Constants ¶
View Source
const ( ASNURL = "https://cdn.jsdelivr.net/npm/@ip-location-db/asn-mmdb/asn.mmdb" CountryURL = "https://cdn.jsdelivr.net/npm/@ip-location-db/geo-whois-asn-country-mmdb/geo-whois-asn-country.mmdb" CityURL = "https://cdn.jsdelivr.net/npm/@ip-location-db/dbip-city-mmdb/dbip-city-ipv4.mmdb" // WHOIS database per AI.md PART 20 WhoisURL = "https://cdn.jsdelivr.net/npm/@ip-location-db/geo-whois-asn-country-mmdb/geo-whois-asn-country.mmdb" )
Database URLs from sapics/ip-location-db (NON-NEGOTIABLE per AI.md)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool `yaml:"enabled"`
Dir string `yaml:"dir"`
Update string `yaml:"update"` // never, daily, weekly, monthly
DenyCountries []string `yaml:"deny_countries"`
AllowedCountries []string `yaml:"allowed_countries"`
// Database toggles
ASN bool `yaml:"asn"`
Country bool `yaml:"country"`
City bool `yaml:"city"`
WHOIS bool `yaml:"whois"` // Enable WHOIS registrant data (per AI.md PART 20)
}
Config holds GeoIP configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default GeoIP configuration Per AI.md PART 20: GeoIP dir is {config_dir}/security/geoip
type Country ¶
type Country struct {
Code string `json:"code"`
Name string `json:"name"`
Continent string `json:"continent"`
}
Country represents country information
type Lookup ¶
type Lookup struct {
// contains filtered or unexported fields
}
Lookup represents a GeoIP lookup service using MMDB format
func (*Lookup) GetCountry ¶
GetCountry returns country info by code
func (*Lookup) LastUpdate ¶
LastUpdate returns the last update time
func (*Lookup) LoadDatabase ¶
LoadDatabase loads a database from path (for backwards compatibility)
func (*Lookup) LoadDatabases ¶
LoadDatabases loads all configured MMDB databases
func (*Lookup) UpdateDatabases ¶
UpdateDatabases updates all databases
type Result ¶
type Result struct {
IP string `json:"ip"`
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
Continent string `json:"continent"`
City string `json:"city,omitempty"`
Region string `json:"region,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
Timezone string `json:"timezone,omitempty"`
ASN uint `json:"asn,omitempty"`
ASNOrg string `json:"asn_org,omitempty"`
// WHOIS registrant data (per AI.md PART 20)
RegistrantOrg string `json:"registrant_org,omitempty"`
RegistrantNet string `json:"registrant_net,omitempty"`
Found bool `json:"found"`
}
Result represents a GeoIP lookup result
Click to show internal directories.
Click to hide internal directories.