Skip to content

Commit 4ae4358

Browse files
committed
Add is_anycast output for location DBs
1 parent 769ffcd commit 4ae4358

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

reader.go

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type Enterprise struct {
7070
AutonomousSystemNumber uint `maxminddb:"autonomous_system_number"`
7171
StaticIPScore float64 `maxminddb:"static_ip_score"`
7272
IsAnonymousProxy bool `maxminddb:"is_anonymous_proxy"`
73+
IsAnycast bool `maxminddb:"is_anycast"`
7374
IsLegitimateProxy bool `maxminddb:"is_legitimate_proxy"`
7475
IsSatelliteProvider bool `maxminddb:"is_satellite_provider"`
7576
} `maxminddb:"traits"`
@@ -130,6 +131,7 @@ type City struct {
130131
} `maxminddb:"location"`
131132
Traits struct {
132133
IsAnonymousProxy bool `maxminddb:"is_anonymous_proxy"`
134+
IsAnycast bool `maxminddb:"is_anycast"`
133135
IsSatelliteProvider bool `maxminddb:"is_satellite_provider"`
134136
} `maxminddb:"traits"`
135137
}
@@ -163,6 +165,7 @@ type Country struct {
163165
} `maxminddb:"represented_country"`
164166
Traits struct {
165167
IsAnonymousProxy bool `maxminddb:"is_anonymous_proxy"`
168+
IsAnycast bool `maxminddb:"is_anycast"`
166169
IsSatelliteProvider bool `maxminddb:"is_satellite_provider"`
167170
} `maxminddb:"traits"`
168171
}

reader_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ func TestReader(t *testing.T) {
118118
assert.False(t, record.RepresentedCountry.IsInEuropeanUnion)
119119
}
120120

121+
func TestIsAnycast(t *testing.T) {
122+
for _, test := range []string{"Country", "City", "Enterprise"} {
123+
t.Run(test, func(t *testing.T) {
124+
reader, err := Open("test-data/test-data/GeoIP2-" + test + "-Test.mmdb")
125+
require.NoError(t, err)
126+
defer reader.Close()
127+
128+
record, err := reader.City(net.ParseIP("214.1.1.0"))
129+
require.NoError(t, err)
130+
131+
assert.True(t, record.Traits.IsAnycast)
132+
})
133+
}
134+
}
135+
121136
func TestMetroCode(t *testing.T) {
122137
reader, err := Open("test-data/test-data/GeoIP2-City-Test.mmdb")
123138
require.NoError(t, err)

test-data

Submodule test-data updated 65 files

0 commit comments

Comments
 (0)