@@ -415,34 +415,74 @@ func (c City) IsZero() bool {
415
415
// The Country struct corresponds to the data in the GeoIP2/GeoLite2
416
416
// Country databases.
417
417
type Country struct {
418
+ // Traits contains various traits associated with the IP address
418
419
Traits struct {
419
- IPAddress netip.Addr `json:"ip_address,omitzero"`
420
- Network netip.Prefix `json:"network,omitzero"`
421
- IsAnycast bool `json:"is_anycast,omitzero" maxminddb:"is_anycast"`
420
+ // IPAddress is the IP address used during the lookup
421
+ IPAddress netip.Addr `json:"ip_address,omitzero"`
422
+ // Network is the network prefix for this record. This is the largest network where all
423
+ // of the fields besides IPAddress have the same value.
424
+ Network netip.Prefix `json:"network,omitzero"`
425
+ // IsAnycast is true if the IP address belongs to an anycast network.
426
+ // See https://en.wikipedia.org/wiki/Anycast
427
+ IsAnycast bool `json:"is_anycast,omitzero" maxminddb:"is_anycast"`
422
428
} `json:"traits,omitzero" maxminddb:"traits"`
429
+ // Continent contains data for the continent record associated with the IP address
423
430
Continent struct {
424
- Names Names `json:"names,omitzero" maxminddb:"names"`
425
- Code string `json:"code,omitzero" maxminddb:"code"`
426
- GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
431
+ // Names contains localized names for the continent
432
+ Names Names `json:"names,omitzero" maxminddb:"names"`
433
+ // Code is a two character continent code like "NA" (North America) or
434
+ // "OC" (Oceania)
435
+ Code string `json:"code,omitzero" maxminddb:"code"`
436
+ // GeoNameID is the GeoName ID for the continent
437
+ GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
427
438
} `json:"continent,omitzero" maxminddb:"continent"`
439
+ // RepresentedCountry contains data for the represented country associated
440
+ // with the IP address. The represented country is the country represented by something like a
441
+ // military base or embassy.
428
442
RepresentedCountry struct {
429
- Names Names `json:"names,omitzero" maxminddb:"names"`
430
- ISOCode string `json:"iso_code,omitzero" maxminddb:"iso_code"`
431
- Type string `json:"type,omitzero" maxminddb:"type"`
432
- GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
433
- IsInEuropeanUnion bool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`
443
+ // Names contains localized names for the represented country
444
+ Names Names `json:"names,omitzero" maxminddb:"names"`
445
+ // ISOCode is the two-character ISO 3166-1 alpha code for the represented
446
+ // country. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
447
+ ISOCode string `json:"iso_code,omitzero" maxminddb:"iso_code"`
448
+ // Type is a string indicating the type of entity that is representing
449
+ // the country. Currently this is only "military" but may expand in the future.
450
+ Type string `json:"type,omitzero" maxminddb:"type"`
451
+ // GeoNameID is the GeoName ID for the represented country
452
+ GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
453
+ // IsInEuropeanUnion is true if the represented country is a member
454
+ // state of the European Union
455
+ IsInEuropeanUnion bool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`
434
456
} `json:"represented_country,omitzero" maxminddb:"represented_country"`
457
+ // Country contains data for the country record associated with the IP
458
+ // address. This record represents the country where MaxMind believes the IP is
459
+ // located.
435
460
Country struct {
436
- Names Names `json:"names,omitzero" maxminddb:"names"`
437
- ISOCode string `json:"iso_code,omitzero" maxminddb:"iso_code"`
438
- GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
439
- IsInEuropeanUnion bool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`
461
+ // Names contains localized names for the country
462
+ Names Names `json:"names,omitzero" maxminddb:"names"`
463
+ // ISOCode is the two-character ISO 3166-1 alpha code for the country.
464
+ // See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
465
+ ISOCode string `json:"iso_code,omitzero" maxminddb:"iso_code"`
466
+ // GeoNameID is the GeoName ID for the country
467
+ GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
468
+ // IsInEuropeanUnion is true if the country is a member state of the
469
+ // European Union
470
+ IsInEuropeanUnion bool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`
440
471
} `json:"country,omitzero" maxminddb:"country"`
472
+ // RegisteredCountry contains data for the registered country associated
473
+ // with the IP address. This record represents the country where the ISP has registered the IP
474
+ // block and may differ from the user's country.
441
475
RegisteredCountry struct {
442
- Names Names `json:"names,omitzero" maxminddb:"names"`
443
- ISOCode string `json:"iso_code,omitzero" maxminddb:"iso_code"`
444
- GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
445
- IsInEuropeanUnion bool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`
476
+ // Names contains localized names for the registered country
477
+ Names Names `json:"names,omitzero" maxminddb:"names"`
478
+ // ISOCode is the two-character ISO 3166-1 alpha code for the registered
479
+ // country. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
480
+ ISOCode string `json:"iso_code,omitzero" maxminddb:"iso_code"`
481
+ // GeoNameID is the GeoName ID for the registered country
482
+ GeoNameID uint `json:"geoname_id,omitzero" maxminddb:"geoname_id"`
483
+ // IsInEuropeanUnion is true if the registered country is a member state
484
+ // of the European Union
485
+ IsInEuropeanUnion bool `json:"is_in_european_union,omitzero" maxminddb:"is_in_european_union"`
446
486
} `json:"registered_country,omitzero" maxminddb:"registered_country"`
447
487
}
448
488
@@ -456,14 +496,27 @@ func (c Country) IsZero() bool {
456
496
// The AnonymousIP struct corresponds to the data in the GeoIP2
457
497
// Anonymous IP database.
458
498
type AnonymousIP struct {
459
- IPAddress netip.Addr `json:"ip_address,omitzero"`
460
- Network netip.Prefix `json:"network,omitzero"`
461
- IsAnonymous bool `json:"is_anonymous,omitzero" maxminddb:"is_anonymous"`
462
- IsAnonymousVPN bool `json:"is_anonymous_vpn,omitzero" maxminddb:"is_anonymous_vpn"`
463
- IsHostingProvider bool `json:"is_hosting_provider,omitzero" maxminddb:"is_hosting_provider"`
464
- IsPublicProxy bool `json:"is_public_proxy,omitzero" maxminddb:"is_public_proxy"`
465
- IsResidentialProxy bool `json:"is_residential_proxy,omitzero" maxminddb:"is_residential_proxy"`
466
- IsTorExitNode bool `json:"is_tor_exit_node,omitzero" maxminddb:"is_tor_exit_node"`
499
+ // IPAddress is the IP address used during the lookup
500
+ IPAddress netip.Addr `json:"ip_address,omitzero"`
501
+ // Network is the network prefix for this record. This is the largest network where all
502
+ // of the fields besides IPAddress have the same value.
503
+ Network netip.Prefix `json:"network,omitzero"`
504
+ // IsAnonymous is true if the IP address belongs to any sort of anonymous network.
505
+ IsAnonymous bool `json:"is_anonymous,omitzero" maxminddb:"is_anonymous"`
506
+ // IsAnonymousVPN is true if the IP address is registered to an anonymous VPN provider.
507
+ // If a VPN provider does not register subnets under names associated with them, we will
508
+ // likely only flag their IP ranges using the IsHostingProvider attribute.
509
+ IsAnonymousVPN bool `json:"is_anonymous_vpn,omitzero" maxminddb:"is_anonymous_vpn"`
510
+ // IsHostingProvider is true if the IP address belongs to a hosting or VPN provider
511
+ // (see description of IsAnonymousVPN attribute).
512
+ IsHostingProvider bool `json:"is_hosting_provider,omitzero" maxminddb:"is_hosting_provider"`
513
+ // IsPublicProxy is true if the IP address belongs to a public proxy.
514
+ IsPublicProxy bool `json:"is_public_proxy,omitzero" maxminddb:"is_public_proxy"`
515
+ // IsResidentialProxy is true if the IP address is on a suspected anonymizing network
516
+ // and belongs to a residential ISP.
517
+ IsResidentialProxy bool `json:"is_residential_proxy,omitzero" maxminddb:"is_residential_proxy"`
518
+ // IsTorExitNode is true if the IP address is a Tor exit node.
519
+ IsTorExitNode bool `json:"is_tor_exit_node,omitzero" maxminddb:"is_tor_exit_node"`
467
520
}
468
521
469
522
var zeroAnonymousIP AnonymousIP
@@ -475,10 +528,16 @@ func (a AnonymousIP) IsZero() bool {
475
528
476
529
// The ASN struct corresponds to the data in the GeoLite2 ASN database.
477
530
type ASN struct {
478
- IPAddress netip.Addr `json:"ip_address,omitzero"`
479
- Network netip.Prefix `json:"network,omitzero"`
480
- AutonomousSystemOrganization string `json:"autonomous_system_organization,omitzero" maxminddb:"autonomous_system_organization"` //nolint:lll // long struct tag
481
- AutonomousSystemNumber uint `json:"autonomous_system_number,omitzero" maxminddb:"autonomous_system_number"` //nolint:lll // long struct tag
531
+ // IPAddress is the IP address used during the lookup
532
+ IPAddress netip.Addr `json:"ip_address,omitzero"`
533
+ // Network is the network prefix for this record. This is the largest network where all
534
+ // of the fields besides IPAddress have the same value.
535
+ Network netip.Prefix `json:"network,omitzero"`
536
+ // AutonomousSystemOrganization is the organization associated with the registered
537
+ // autonomous system number for the IP address.
538
+ AutonomousSystemOrganization string `json:"autonomous_system_organization,omitzero" maxminddb:"autonomous_system_organization"` //nolint:lll // long struct tag
539
+ // AutonomousSystemNumber is the autonomous system number associated with the IP address.
540
+ AutonomousSystemNumber uint `json:"autonomous_system_number,omitzero" maxminddb:"autonomous_system_number"` //nolint:lll // long struct tag
482
541
}
483
542
484
543
var zeroASN ASN
0 commit comments