Skip to content

Commit 7c814ad

Browse files
committed
Deprecate IsLegitimateProxy and StaticIPScore
MaxMind has deprecated IsLegitimateProxy and StaticIPScore was added in error and has never been populated. Both fields will be removed in the next major release. Also refactored HasData() methods on trait structs to use zero-value comparison for easier maintenance.
1 parent 106ff37 commit 7c814ad

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changes
22

3+
## 2.0.2
4+
5+
- Deprecated `IsLegitimateProxy` on `EnterpriseTraits`. MaxMind has deprecated
6+
this field and it will be removed in the next major release.
7+
- Deprecated `StaticIPScore` on `EnterpriseTraits`. This field was added in
8+
error and has never been populated. It will be removed in the next major
9+
release.
10+
311
## 2.0.1 - 2025-11-26
412

513
- Upgraded `github.com/oschwald/geoip2-golang/v2` to 2.1.1, which fixes an

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,7 @@ func main() {
374374
fmt.Printf("Connection Type: %v\n", record.Traits.ConnectionType)
375375
fmt.Printf("Domain: %v\n", record.Traits.Domain)
376376
fmt.Printf("User Type: %v\n", record.Traits.UserType)
377-
fmt.Printf("Static IP Score: %v\n", record.Traits.StaticIPScore)
378377
fmt.Printf("Is Anycast: %v\n", record.Traits.IsAnycast)
379-
fmt.Printf("Is Legitimate Proxy: %v\n", record.Traits.IsLegitimateProxy)
380378

381379
// Mobile carrier information (if available)
382380
if record.Traits.MobileCountryCode != "" {

models.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ var (
3535
zeroEnterprisePostal EnterprisePostal
3636
zeroEnterpriseSubdivision EnterpriseSubdivision
3737
zeroEnterpriseCountryRecord EnterpriseCountryRecord
38+
zeroEnterpriseTraits EnterpriseTraits
39+
zeroCityTraits CityTraits
40+
zeroCountryTraits CountryTraits
3841
)
3942

4043
// HasData returns true if the Names struct has any localized names.
@@ -227,27 +230,29 @@ type EnterpriseTraits struct {
227230
// UserType indicates the user type associated with the IP address
228231
// (business, cafe, cellular, college, etc.)
229232
UserType string `json:"user_type,omitzero" maxminddb:"user_type"`
230-
// StaticIPScore is an indicator of how static or dynamic an IP address
231-
// is, ranging from 0 to 99.99
233+
// StaticIPScore was added in error and has never been populated.
234+
//
235+
// Deprecated: This field will be removed in the next major release.
232236
StaticIPScore float64 `json:"static_ip_score,omitzero" maxminddb:"static_ip_score"`
233237
// AutonomousSystemNumber for the IP address
234238
AutonomousSystemNumber uint `json:"autonomous_system_number,omitzero" maxminddb:"autonomous_system_number"`
235239
// IsAnycast is true if the IP address belongs to an anycast network.
236240
// See https://en.wikipedia.org/wiki/Anycast
237241
IsAnycast bool `json:"is_anycast,omitzero" maxminddb:"is_anycast"`
238242
// IsLegitimateProxy is true if MaxMind believes this IP address to be a
239-
// legitimate proxy, such as an internal VPN used by a corporation
243+
// legitimate proxy, such as an internal VPN used by a corporation.
244+
//
245+
// Deprecated: MaxMind has deprecated this field. It will be removed in
246+
// the next major release.
240247
IsLegitimateProxy bool `json:"is_legitimate_proxy,omitzero" maxminddb:"is_legitimate_proxy"`
241248
}
242249

243250
// HasData returns true if the EnterpriseTraits has any data (excluding Network and IPAddress).
244251
func (t EnterpriseTraits) HasData() bool {
245-
return t.AutonomousSystemOrganization != "" || t.ConnectionType != "" ||
246-
t.Domain != "" || t.ISP != "" || t.MobileCountryCode != "" ||
247-
t.MobileNetworkCode != "" || t.Organization != "" ||
248-
t.UserType != "" || t.StaticIPScore != 0 ||
249-
t.AutonomousSystemNumber != 0 || t.IsAnycast ||
250-
t.IsLegitimateProxy
252+
cmp := t
253+
cmp.Network = zeroEnterpriseTraits.Network
254+
cmp.IPAddress = zeroEnterpriseTraits.IPAddress
255+
return cmp != zeroEnterpriseTraits
251256
}
252257

253258
// City/Country-specific types
@@ -323,7 +328,10 @@ type CityTraits struct {
323328

324329
// HasData returns true if the CityTraits has any data (excluding Network and IPAddress).
325330
func (t CityTraits) HasData() bool {
326-
return t.IsAnycast
331+
cmp := t
332+
cmp.Network = zeroCityTraits.Network
333+
cmp.IPAddress = zeroCityTraits.IPAddress
334+
return cmp != zeroCityTraits
327335
}
328336

329337
// CountryTraits contains traits data for Country database records.
@@ -340,7 +348,10 @@ type CountryTraits struct {
340348

341349
// HasData returns true if the CountryTraits has any data (excluding Network and IPAddress).
342350
func (t CountryTraits) HasData() bool {
343-
return t.IsAnycast
351+
cmp := t
352+
cmp.Network = zeroCountryTraits.Network
353+
cmp.IPAddress = zeroCountryTraits.IPAddress
354+
return cmp != zeroCountryTraits
344355
}
345356

346357
// The Enterprise struct corresponds to the data in the GeoIP2 Enterprise

0 commit comments

Comments
 (0)