Skip to content

Commit 0972ffa

Browse files
authored
Merge pull request oschwald#119 from oschwald/greg/add-is-anycast
Add is_anycast
2 parents 769ffcd + 3d75aca commit 0972ffa

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/oschwald/geoip2-golang
33
go 1.21
44

55
require (
6-
github.com/oschwald/maxminddb-golang v1.12.0
6+
github.com/oschwald/maxminddb-golang v1.13.0
77
github.com/stretchr/testify v1.9.0
88
)
99

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
4-
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
3+
github.com/oschwald/maxminddb-golang v1.13.0 h1:R8xBorY71s84yO06NgTmQvqvTvlS/bnYZrrWX1MElnU=
4+
github.com/oschwald/maxminddb-golang v1.13.0/go.mod h1:BU0z8BfFVhi1LQaonTwwGQlsHUEu9pWNdMfmq4ztm0o=
55
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
77
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
88
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
9-
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
10-
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
119
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
1210
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1311
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

reader.go

Lines changed: 3 additions & 0 deletions
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

Lines changed: 15 additions & 0 deletions
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)