Add GeoIP support for unique IP aggregation
- Introduced GeoIP configuration options in config.example.yaml to enable geolocation lookups for the /api/agg/unique-ips endpoint. - Updated the aggregate handler to include optional GeoIP data in responses, enriching unique IP information with country and city details, as well as ASN data if available. - Enhanced documentation in AGGREGATE.md and README.md to reflect the new GeoIP functionality and its usage. - Added a dependency on the geoip2-golang library in go.mod for GeoIP lookups. - Modified tests to accommodate the new GeoIP integration in the aggregate handler.
This commit is contained in:
@@ -21,6 +21,17 @@ type Config struct {
|
||||
TrustedProxies []string `yaml:"trusted_proxies"`
|
||||
Servers []Server `yaml:"servers"`
|
||||
Aggregate *AggregateConfig `yaml:"aggregate"`
|
||||
GeoIP *GeoIPConfig `yaml:"geoip"`
|
||||
}
|
||||
|
||||
// GeoIPConfig enables GeoLite2 lookups for /api/agg/unique-ips (optional).
|
||||
// Нужен хотя бы один из: database_path (City) или asn_database_path (ASN). Country-only DB не используется — страна в City.
|
||||
type GeoIPConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
DatabasePath string `yaml:"database_path"` // GeoLite2-City.mmdb
|
||||
DownloadURL string `yaml:"download_url"` // если city-файла нет; .mmdb или .gz
|
||||
AsnDatabasePath string `yaml:"asn_database_path"` // GeoLite2-ASN.mmdb
|
||||
AsnDownloadURL string `yaml:"asn_download_url"` // если asn-файла нет
|
||||
}
|
||||
|
||||
// AggregateConfig controls default scope of /api/agg/* (optional).
|
||||
|
||||
Reference in New Issue
Block a user