maxmind-geoip2 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +114 -0
- data/README.dev.md +1 -1
- data/README.md +26 -6
- data/Rakefile +1 -0
- data/lib/maxmind/geoip2/client.rb +18 -9
- data/lib/maxmind/geoip2/model/anonymous_plus.rb +46 -0
- data/lib/maxmind/geoip2/model/city.rb +5 -6
- data/lib/maxmind/geoip2/model/connection_type.rb +3 -2
- data/lib/maxmind/geoip2/model/enterprise.rb +2 -3
- data/lib/maxmind/geoip2/model/insights.rb +3 -5
- data/lib/maxmind/geoip2/reader.rb +26 -1
- data/lib/maxmind/geoip2/record/location.rb +3 -3
- data/lib/maxmind/geoip2/record/traits.rb +40 -28
- data/lib/maxmind/geoip2/version.rb +8 -0
- data/maxmind-geoip2.gemspec +11 -6
- data/test/data/LICENSE-APACHE +202 -0
- data/test/data/LICENSE-MIT +17 -0
- data/test/data/MaxMind-DB-spec.md +1 -2
- data/test/data/README.md +8 -1
- data/test/data/cmd/write-test-data/main.go +68 -0
- data/test/data/go.mod +13 -0
- data/test/data/go.sum +16 -0
- data/test/data/pkg/writer/decoder.go +178 -0
- data/test/data/pkg/writer/geoip2.go +184 -0
- data/test/data/pkg/writer/ip.go +39 -0
- data/test/data/pkg/writer/maxmind.go +246 -0
- data/test/data/pkg/writer/nestedstructures.go +73 -0
- data/test/data/pkg/writer/writer.go +61 -0
- data/test/data/source-data/GeoIP-Anonymous-Plus-Test.json +175 -0
- data/test/data/source-data/GeoIP2-Anonymous-IP-Test.json +6 -0
- data/test/data/source-data/GeoIP2-City-Test.json +392 -5
- data/test/data/source-data/GeoIP2-Connection-Type-Test.json +15 -10
- data/test/data/source-data/GeoIP2-Country-Test.json +99 -25
- data/test/data/source-data/GeoIP2-Domain-Test.json +5 -0
- data/test/data/source-data/GeoIP2-Enterprise-Test.json +371 -6
- data/test/data/source-data/GeoIP2-IP-Risk-Test.json +31 -0
- data/test/data/source-data/GeoIP2-Precision-Enterprise-Sandbox-Test.json +296 -0
- data/test/data/source-data/GeoIP2-Precision-Enterprise-Test.json +1159 -175
- data/test/data/source-data/GeoIP2-Static-IP-Score-Test.json +15 -0
- data/test/data/source-data/GeoIP2-User-Count-Test.json +18 -0
- data/test/data/source-data/GeoLite2-City-Test.json +168 -3
- data/test/data/source-data/GeoLite2-Country-Test.json +92 -3
- data/test/data/test-data/GeoIP-Anonymous-Plus-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb +0 -0
- data/test/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb +0 -0
- data/test/data/test-data/GeoIP2-City-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Connection-Type-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Country-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-DensityIncome-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Domain-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Enterprise-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-IP-Risk-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-ISP-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Static-IP-Score-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-User-Count-Test.mmdb +0 -0
- data/test/data/test-data/GeoLite2-ASN-Test.mmdb +0 -0
- data/test/data/test-data/GeoLite2-City-Test.mmdb +0 -0
- data/test/data/test-data/GeoLite2-Country-Test.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-string-value-entries.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-decoder.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv4-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv4-28.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv4-32.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv6-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv6-28.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv6-32.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-mixed-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-mixed-28.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-mixed-32.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-nested.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-pointer-decoder.mmdb +0 -0
- data/test/data/test-data/README.md +28 -12
- data/test/test_client.rb +18 -2
- data/test/test_reader.rb +42 -1
- metadata +25 -13
- data/test/data/LICENSE +0 -4
- data/test/data/perltidyrc +0 -12
- data/test/data/source-data/README +0 -15
- data/test/data/test-data/write-test-data.pl +0 -695
@@ -734,6 +734,21 @@
|
|
734
734
|
"score" : 1.47
|
735
735
|
}
|
736
736
|
},
|
737
|
+
{
|
738
|
+
"::214.2.3.0/126" : {
|
739
|
+
"score" : 0.04
|
740
|
+
}
|
741
|
+
},
|
742
|
+
{
|
743
|
+
"::214.2.3.4/128" : {
|
744
|
+
"score" : 0.05
|
745
|
+
}
|
746
|
+
},
|
747
|
+
{
|
748
|
+
"::214.2.3.5/128" : {
|
749
|
+
"score" : 0.06
|
750
|
+
}
|
751
|
+
},
|
737
752
|
{
|
738
753
|
"::1:0:0:0/80" : {
|
739
754
|
"score" : 1.48
|
@@ -881,6 +881,24 @@
|
|
881
881
|
"ipv4_32" : 0
|
882
882
|
}
|
883
883
|
},
|
884
|
+
{
|
885
|
+
"::214.2.3.0/126" : {
|
886
|
+
"ipv4_24" : 4,
|
887
|
+
"ipv4_32" : 0
|
888
|
+
}
|
889
|
+
},
|
890
|
+
{
|
891
|
+
"::214.2.3.4/128" : {
|
892
|
+
"ipv4_24" : 4,
|
893
|
+
"ipv4_32" : 3
|
894
|
+
}
|
895
|
+
},
|
896
|
+
{
|
897
|
+
"::214.2.3.5/128" : {
|
898
|
+
"ipv4_24" : 4,
|
899
|
+
"ipv4_32" : 1
|
900
|
+
}
|
901
|
+
},
|
884
902
|
{
|
885
903
|
"::1:0:0:0/80" : {
|
886
904
|
"ipv6_32" : 0,
|
@@ -132,9 +132,6 @@
|
|
132
132
|
"ru" : "Румыния",
|
133
133
|
"zh-CN" : "罗马尼亚"
|
134
134
|
}
|
135
|
-
},
|
136
|
-
"traits" : {
|
137
|
-
"is_anonymous_proxy" : true
|
138
135
|
}
|
139
136
|
}
|
140
137
|
},
|
@@ -12800,5 +12797,173 @@
|
|
12800
12797
|
}
|
12801
12798
|
}
|
12802
12799
|
}
|
12800
|
+
},
|
12801
|
+
{
|
12802
|
+
"214.78.0.0/19" : {
|
12803
|
+
"city" : {
|
12804
|
+
"geoname_id" : 5391811,
|
12805
|
+
"names" : {
|
12806
|
+
"de" : "San Diego",
|
12807
|
+
"en" : "San Diego",
|
12808
|
+
"es" : "San Diego",
|
12809
|
+
"fr" : "San Diego",
|
12810
|
+
"ja" : "サンディエゴ",
|
12811
|
+
"pt-BR" : "San Diego",
|
12812
|
+
"ru" : "Сан-Диего"
|
12813
|
+
}
|
12814
|
+
},
|
12815
|
+
"continent" : {
|
12816
|
+
"code" : "NA",
|
12817
|
+
"geoname_id" : 6255149,
|
12818
|
+
"names" : {
|
12819
|
+
"de" : "Nordamerika",
|
12820
|
+
"en" : "North America",
|
12821
|
+
"es" : "Norteamérica",
|
12822
|
+
"fr" : "Amérique du Nord",
|
12823
|
+
"ja" : "北アメリカ",
|
12824
|
+
"pt-BR" : "América do Norte",
|
12825
|
+
"ru" : "Северная Америка",
|
12826
|
+
"zh-CN" : "北美洲"
|
12827
|
+
}
|
12828
|
+
},
|
12829
|
+
"country" : {
|
12830
|
+
"geoname_id" : 6252001,
|
12831
|
+
"iso_code" : "US",
|
12832
|
+
"names" : {
|
12833
|
+
"de" : "Vereinigte Staaten",
|
12834
|
+
"en" : "United States",
|
12835
|
+
"es" : "Estados Unidos",
|
12836
|
+
"fr" : "États Unis",
|
12837
|
+
"ja" : "アメリカ",
|
12838
|
+
"pt-BR" : "EUA",
|
12839
|
+
"ru" : "США",
|
12840
|
+
"zh-CN" : "美国"
|
12841
|
+
}
|
12842
|
+
},
|
12843
|
+
"location" : {
|
12844
|
+
"accuracy_radius" : 10,
|
12845
|
+
"latitude" : 32.6783,
|
12846
|
+
"longitude" : -117.1291,
|
12847
|
+
"metro_code" : 825,
|
12848
|
+
"time_zone" : "America/Los_Angeles"
|
12849
|
+
},
|
12850
|
+
"postal" : {
|
12851
|
+
"code" : "92136"
|
12852
|
+
},
|
12853
|
+
"registered_country" : {
|
12854
|
+
"geoname_id" : 6252001,
|
12855
|
+
"iso_code" : "US",
|
12856
|
+
"names" : {
|
12857
|
+
"de" : "Vereinigte Staaten",
|
12858
|
+
"en" : "United States",
|
12859
|
+
"es" : "Estados Unidos",
|
12860
|
+
"fr" : "États Unis",
|
12861
|
+
"ja" : "アメリカ",
|
12862
|
+
"pt-BR" : "EUA",
|
12863
|
+
"ru" : "США",
|
12864
|
+
"zh-CN" : "美国"
|
12865
|
+
}
|
12866
|
+
},
|
12867
|
+
"subdivisions" : [
|
12868
|
+
{
|
12869
|
+
"geoname_id" : 5332921,
|
12870
|
+
"iso_code" : "CA",
|
12871
|
+
"names" : {
|
12872
|
+
"de" : "Kalifornien",
|
12873
|
+
"en" : "California",
|
12874
|
+
"es" : "California",
|
12875
|
+
"fr" : "Californie",
|
12876
|
+
"ja" : "カリフォルニア州",
|
12877
|
+
"pt-BR" : "Califórnia",
|
12878
|
+
"ru" : "Калифорния",
|
12879
|
+
"zh-CN" : "加州"
|
12880
|
+
}
|
12881
|
+
}
|
12882
|
+
]
|
12883
|
+
}
|
12884
|
+
},
|
12885
|
+
{
|
12886
|
+
"2001:480::/43" : {
|
12887
|
+
"city" : {
|
12888
|
+
"geoname_id" : 5391811,
|
12889
|
+
"names" : {
|
12890
|
+
"de" : "San Diego",
|
12891
|
+
"en" : "San Diego",
|
12892
|
+
"es" : "San Diego",
|
12893
|
+
"fr" : "San Diego",
|
12894
|
+
"ja" : "サンディエゴ",
|
12895
|
+
"pt-BR" : "San Diego",
|
12896
|
+
"ru" : "Сан-Диего"
|
12897
|
+
}
|
12898
|
+
},
|
12899
|
+
"continent" : {
|
12900
|
+
"code" : "NA",
|
12901
|
+
"geoname_id" : 6255149,
|
12902
|
+
"names" : {
|
12903
|
+
"de" : "Nordamerika",
|
12904
|
+
"en" : "North America",
|
12905
|
+
"es" : "Norteamérica",
|
12906
|
+
"fr" : "Amérique du Nord",
|
12907
|
+
"ja" : "北アメリカ",
|
12908
|
+
"pt-BR" : "América do Norte",
|
12909
|
+
"ru" : "Северная Америка",
|
12910
|
+
"zh-CN" : "北美洲"
|
12911
|
+
}
|
12912
|
+
},
|
12913
|
+
"country" : {
|
12914
|
+
"geoname_id" : 6252001,
|
12915
|
+
"iso_code" : "US",
|
12916
|
+
"names" : {
|
12917
|
+
"de" : "Vereinigte Staaten",
|
12918
|
+
"en" : "United States",
|
12919
|
+
"es" : "Estados Unidos",
|
12920
|
+
"fr" : "États Unis",
|
12921
|
+
"ja" : "アメリカ",
|
12922
|
+
"pt-BR" : "EUA",
|
12923
|
+
"ru" : "США",
|
12924
|
+
"zh-CN" : "美国"
|
12925
|
+
}
|
12926
|
+
},
|
12927
|
+
"location" : {
|
12928
|
+
"accuracy_radius" : 50,
|
12929
|
+
"latitude" : 32.7203,
|
12930
|
+
"longitude" : -117.1552,
|
12931
|
+
"metro_code" : 825,
|
12932
|
+
"time_zone" : "America/Los_Angeles"
|
12933
|
+
},
|
12934
|
+
"postal" : {
|
12935
|
+
"code" : "92101"
|
12936
|
+
},
|
12937
|
+
"registered_country" : {
|
12938
|
+
"geoname_id" : 6252001,
|
12939
|
+
"iso_code" : "US",
|
12940
|
+
"names" : {
|
12941
|
+
"de" : "Vereinigte Staaten",
|
12942
|
+
"en" : "United States",
|
12943
|
+
"es" : "Estados Unidos",
|
12944
|
+
"fr" : "États Unis",
|
12945
|
+
"ja" : "アメリカ",
|
12946
|
+
"pt-BR" : "EUA",
|
12947
|
+
"ru" : "США",
|
12948
|
+
"zh-CN" : "美国"
|
12949
|
+
}
|
12950
|
+
},
|
12951
|
+
"subdivisions" : [
|
12952
|
+
{
|
12953
|
+
"geoname_id" : 5332921,
|
12954
|
+
"iso_code" : "CA",
|
12955
|
+
"names" : {
|
12956
|
+
"de" : "Kalifornien",
|
12957
|
+
"en" : "California",
|
12958
|
+
"es" : "California",
|
12959
|
+
"fr" : "Californie",
|
12960
|
+
"ja" : "カリフォルニア州",
|
12961
|
+
"pt-BR" : "Califórnia",
|
12962
|
+
"ru" : "Калифорния",
|
12963
|
+
"zh-CN" : "加州"
|
12964
|
+
}
|
12965
|
+
}
|
12966
|
+
]
|
12967
|
+
}
|
12803
12968
|
}
|
12804
12969
|
]
|
@@ -136,9 +136,6 @@
|
|
136
136
|
"ru" : "Румыния",
|
137
137
|
"zh-CN" : "罗马尼亚"
|
138
138
|
}
|
139
|
-
},
|
140
|
-
"traits" : {
|
141
|
-
"is_anonymous_proxy" : true
|
142
139
|
}
|
143
140
|
}
|
144
141
|
},
|
@@ -11276,5 +11273,97 @@
|
|
11276
11273
|
}
|
11277
11274
|
}
|
11278
11275
|
}
|
11276
|
+
},
|
11277
|
+
{
|
11278
|
+
"214.78.0.0/19" : {
|
11279
|
+
"continent" : {
|
11280
|
+
"code" : "NA",
|
11281
|
+
"geoname_id" : 6255149,
|
11282
|
+
"names" : {
|
11283
|
+
"de" : "Nordamerika",
|
11284
|
+
"en" : "North America",
|
11285
|
+
"es" : "Norteamérica",
|
11286
|
+
"fr" : "Amérique du Nord",
|
11287
|
+
"ja" : "北アメリカ",
|
11288
|
+
"pt-BR" : "América do Norte",
|
11289
|
+
"ru" : "Северная Америка",
|
11290
|
+
"zh-CN" : "北美洲"
|
11291
|
+
}
|
11292
|
+
},
|
11293
|
+
"country" : {
|
11294
|
+
"geoname_id" : 6252001,
|
11295
|
+
"iso_code" : "US",
|
11296
|
+
"names" : {
|
11297
|
+
"de" : "Vereinigte Staaten",
|
11298
|
+
"en" : "United States",
|
11299
|
+
"es" : "Estados Unidos",
|
11300
|
+
"fr" : "États Unis",
|
11301
|
+
"ja" : "アメリカ",
|
11302
|
+
"pt-BR" : "EUA",
|
11303
|
+
"ru" : "США",
|
11304
|
+
"zh-CN" : "美国"
|
11305
|
+
}
|
11306
|
+
},
|
11307
|
+
"registered_country" : {
|
11308
|
+
"geoname_id" : 6252001,
|
11309
|
+
"iso_code" : "US",
|
11310
|
+
"names" : {
|
11311
|
+
"de" : "Vereinigte Staaten",
|
11312
|
+
"en" : "United States",
|
11313
|
+
"es" : "Estados Unidos",
|
11314
|
+
"fr" : "États Unis",
|
11315
|
+
"ja" : "アメリカ",
|
11316
|
+
"pt-BR" : "EUA",
|
11317
|
+
"ru" : "США",
|
11318
|
+
"zh-CN" : "美国"
|
11319
|
+
}
|
11320
|
+
}
|
11321
|
+
}
|
11322
|
+
},
|
11323
|
+
{
|
11324
|
+
"2001:480::/43" : {
|
11325
|
+
"continent" : {
|
11326
|
+
"code" : "NA",
|
11327
|
+
"geoname_id" : 6255149,
|
11328
|
+
"names" : {
|
11329
|
+
"de" : "Nordamerika",
|
11330
|
+
"en" : "North America",
|
11331
|
+
"es" : "Norteamérica",
|
11332
|
+
"fr" : "Amérique du Nord",
|
11333
|
+
"ja" : "北アメリカ",
|
11334
|
+
"pt-BR" : "América do Norte",
|
11335
|
+
"ru" : "Северная Америка",
|
11336
|
+
"zh-CN" : "北美洲"
|
11337
|
+
}
|
11338
|
+
},
|
11339
|
+
"country" : {
|
11340
|
+
"geoname_id" : 6252001,
|
11341
|
+
"iso_code" : "US",
|
11342
|
+
"names" : {
|
11343
|
+
"de" : "Vereinigte Staaten",
|
11344
|
+
"en" : "United States",
|
11345
|
+
"es" : "Estados Unidos",
|
11346
|
+
"fr" : "États Unis",
|
11347
|
+
"ja" : "アメリカ",
|
11348
|
+
"pt-BR" : "EUA",
|
11349
|
+
"ru" : "США",
|
11350
|
+
"zh-CN" : "美国"
|
11351
|
+
}
|
11352
|
+
},
|
11353
|
+
"registered_country" : {
|
11354
|
+
"geoname_id" : 6252001,
|
11355
|
+
"iso_code" : "US",
|
11356
|
+
"names" : {
|
11357
|
+
"de" : "Vereinigte Staaten",
|
11358
|
+
"en" : "United States",
|
11359
|
+
"es" : "Estados Unidos",
|
11360
|
+
"fr" : "États Unis",
|
11361
|
+
"ja" : "アメリカ",
|
11362
|
+
"pt-BR" : "EUA",
|
11363
|
+
"ru" : "США",
|
11364
|
+
"zh-CN" : "美国"
|
11365
|
+
}
|
11366
|
+
}
|
11367
|
+
}
|
11279
11368
|
}
|
11280
11369
|
]
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,13 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
## How to generate test data
|
2
|
+
Use the [write-test-data](https://github.com/maxmind/MaxMind-DB/blob/main/cmd/write-test-data)
|
3
|
+
go tool to create a small set of test databases with a variety of data and
|
4
|
+
record sizes.
|
3
5
|
|
4
6
|
These test databases are useful for testing code that reads MaxMind DB files.
|
5
7
|
|
6
|
-
There is also a `maps-with-pointers.raw` file. This contains the raw output of
|
7
|
-
the MaxMind::DB::Writer::Serializer module, when given a series of maps which
|
8
|
-
share some keys and values. It is used to test that decoder code can handle
|
9
|
-
pointers to map keys and values, as well as to the whole map.
|
10
|
-
|
11
8
|
There are several ways to figure out what IP addresses are actually in the
|
12
9
|
test databases. You can take a look at the
|
13
10
|
[source-data directory](https://github.com/maxmind/MaxMind-DB/tree/main/source-data)
|
@@ -19,8 +16,27 @@ You can also use the
|
|
19
16
|
in the
|
20
17
|
[MaxMind-DB-Reader-perl repository](https://github.com/maxmind/MaxMind-DB-Reader-perl).
|
21
18
|
|
22
|
-
|
23
|
-
the
|
24
|
-
[
|
25
|
-
|
26
|
-
|
19
|
+
## Static test data
|
20
|
+
Some of the test files are remnants of the
|
21
|
+
[old perl test data writer](https://github.com/maxmind/MaxMind-DB/blob/f0a85c671c5b6e9c5e514bd66162724ee1dedea3/test-data/write-test-data.pl)
|
22
|
+
and cannot be generated with the go tool. These databases are intentionally broken,
|
23
|
+
and exploited functionality simply not available in the go mmdbwriter:
|
24
|
+
|
25
|
+
- MaxMind-DB-test-broken-pointers-24.mmdb
|
26
|
+
- MaxMind-DB-test-broken-search-tree-24.mmdb
|
27
|
+
- MaxMind-DB-test-pointer-decoder.mmdb
|
28
|
+
- GeoIP2-City-Test-Broken-Double-Format.mmdb
|
29
|
+
- GeoIP2-City-Test-Invalid-Node-Count.mmdb
|
30
|
+
- maps-with-pointers.raw
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
```
|
34
|
+
Usage of ./write-test-data:
|
35
|
+
-source string
|
36
|
+
Source data directory
|
37
|
+
-target string
|
38
|
+
Destination directory for the generated mmdb files
|
39
|
+
```
|
40
|
+
|
41
|
+
Example:
|
42
|
+
`./write-test-data --source ../../source-data --target ../../test-data`
|
data/test/test_client.rb
CHANGED
@@ -22,6 +22,7 @@ class ClientTest < Minitest::Test
|
|
22
22
|
},
|
23
23
|
'traits' => {
|
24
24
|
'ip_address' => '1.2.3.4',
|
25
|
+
'is_anycast' => true,
|
25
26
|
'network' => '1.2.3.0/24',
|
26
27
|
},
|
27
28
|
}.freeze
|
@@ -42,6 +43,7 @@ class ClientTest < Minitest::Test
|
|
42
43
|
},
|
43
44
|
'traits' => {
|
44
45
|
'ip_address' => '1.2.3.40',
|
46
|
+
'is_anycast' => true,
|
45
47
|
'is_residential_proxy' => true,
|
46
48
|
'network' => '1.2.3.0/24',
|
47
49
|
'static_ip_score' => 1.3,
|
@@ -73,6 +75,7 @@ class ClientTest < Minitest::Test
|
|
73
75
|
|
74
76
|
assert_equal(false, record.registered_country.in_european_union?)
|
75
77
|
|
78
|
+
assert_equal(true, record.traits.anycast?)
|
76
79
|
assert_equal('1.2.3.0/24', record.traits.network)
|
77
80
|
end
|
78
81
|
|
@@ -83,6 +86,7 @@ class ClientTest < Minitest::Test
|
|
83
86
|
|
84
87
|
assert_equal(42, record.continent.geoname_id)
|
85
88
|
|
89
|
+
assert_equal(true, record.traits.anycast?)
|
86
90
|
assert_equal(true, record.traits.residential_proxy?)
|
87
91
|
assert_equal('1.2.3.0/24', record.traits.network)
|
88
92
|
assert_equal(1.3, record.traits.static_ip_score)
|
@@ -126,7 +130,7 @@ class ClientTest < Minitest::Test
|
|
126
130
|
)
|
127
131
|
end
|
128
132
|
|
129
|
-
def
|
133
|
+
def test_invalid_ip_error_from_web_service
|
130
134
|
error = assert_raises(
|
131
135
|
MaxMind::GeoIP2::AddressInvalidError,
|
132
136
|
) { request(:country, '1.2.3.6') }
|
@@ -137,6 +141,17 @@ class ClientTest < Minitest::Test
|
|
137
141
|
)
|
138
142
|
end
|
139
143
|
|
144
|
+
def test_invalid_ip_error_from_client
|
145
|
+
error = assert_raises(
|
146
|
+
MaxMind::GeoIP2::AddressInvalidError,
|
147
|
+
) { request(:country, '1.2.3') }
|
148
|
+
|
149
|
+
assert_equal(
|
150
|
+
'The value "1.2.3" is not a valid IP address',
|
151
|
+
error.message,
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
140
155
|
def test_no_error_body_ip_error
|
141
156
|
assert_raises(
|
142
157
|
JSON::ParserError,
|
@@ -290,7 +305,7 @@ class ClientTest < Minitest::Test
|
|
290
305
|
license_key: 'abcdef123456',
|
291
306
|
)
|
292
307
|
|
293
|
-
client.send(method,
|
308
|
+
client.send(method, ip_address)
|
294
309
|
end
|
295
310
|
|
296
311
|
def get_response(ip_address)
|
@@ -300,6 +315,7 @@ class ClientTest < Minitest::Test
|
|
300
315
|
headers: { 'Content-Type': CONTENT_TYPES[:country] },
|
301
316
|
status: 200,
|
302
317
|
},
|
318
|
+
'1.2.3' => {},
|
303
319
|
'1.2.3.4' => {
|
304
320
|
body: JSON.generate(COUNTRY),
|
305
321
|
headers: { 'Content-Type': CONTENT_TYPES[:country] },
|
data/test/test_reader.rb
CHANGED
@@ -37,6 +37,29 @@ class ReaderTest < Minitest::Test
|
|
37
37
|
reader.close
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_anonymous_plus
|
41
|
+
reader = MaxMind::GeoIP2::Reader.new(
|
42
|
+
'test/data/test-data/GeoIP-Anonymous-Plus-Test.mmdb',
|
43
|
+
)
|
44
|
+
ip = '1.2.0.1'
|
45
|
+
record = reader.anonymous_plus(ip)
|
46
|
+
|
47
|
+
assert_equal(30, record.anonymizer_confidence)
|
48
|
+
assert_equal(true, record.anonymous?)
|
49
|
+
assert_equal(true, record.anonymous_vpn?)
|
50
|
+
assert_equal(false, record.hosting_provider?)
|
51
|
+
assert_equal(Date.new(2025, 4, 14), record.network_last_seen)
|
52
|
+
assert_equal('foo', record.provider_name)
|
53
|
+
assert_equal(false, record.public_proxy?)
|
54
|
+
assert_equal(false, record.residential_proxy?)
|
55
|
+
assert_equal(false, record.tor_exit_node?)
|
56
|
+
|
57
|
+
assert_equal(ip, record.ip_address)
|
58
|
+
assert_equal('1.2.0.1/32', record.network)
|
59
|
+
|
60
|
+
reader.close
|
61
|
+
end
|
62
|
+
|
40
63
|
def test_asn
|
41
64
|
reader = MaxMind::GeoIP2::Reader.new(
|
42
65
|
'test/data/test-data/GeoLite2-ASN-Test.mmdb',
|
@@ -97,6 +120,12 @@ class ReaderTest < Minitest::Test
|
|
97
120
|
assert_equal('WA', record.most_specific_subdivision.iso_code)
|
98
121
|
)
|
99
122
|
|
123
|
+
# This IP has is_anycast.
|
124
|
+
|
125
|
+
ip_address = '214.1.1.0'
|
126
|
+
record = reader.city(ip_address)
|
127
|
+
assert_equal(true, record.traits.anycast?)
|
128
|
+
|
100
129
|
reader.close
|
101
130
|
end
|
102
131
|
|
@@ -119,7 +148,7 @@ class ReaderTest < Minitest::Test
|
|
119
148
|
ip = '1.0.1.1'
|
120
149
|
record = reader.connection_type(ip)
|
121
150
|
|
122
|
-
assert_equal('
|
151
|
+
assert_equal('Cellular', record.connection_type)
|
123
152
|
assert_equal(ip, record.ip_address)
|
124
153
|
assert_equal('1.0.1.0/24', record.network)
|
125
154
|
|
@@ -209,6 +238,12 @@ class ReaderTest < Minitest::Test
|
|
209
238
|
assert_equal('81.2.69.163', record.traits.ip_address)
|
210
239
|
assert_equal('81.2.69.160/27', record.traits.network)
|
211
240
|
|
241
|
+
# This IP has is_anycast.
|
242
|
+
|
243
|
+
ip_address = '214.1.1.0'
|
244
|
+
record = reader.country(ip_address)
|
245
|
+
assert_equal(true, record.traits.anycast?)
|
246
|
+
|
212
247
|
assert_raises(NoMethodError) { record.foo }
|
213
248
|
reader.close
|
214
249
|
end
|
@@ -274,6 +309,12 @@ class ReaderTest < Minitest::Test
|
|
274
309
|
assert_equal('310', record.traits.mobile_country_code)
|
275
310
|
assert_equal('004', record.traits.mobile_network_code)
|
276
311
|
|
312
|
+
# This IP has is_anycast.
|
313
|
+
|
314
|
+
ip_address = '214.1.1.0'
|
315
|
+
record = reader.enterprise(ip_address)
|
316
|
+
assert_equal(true, record.traits.anycast?)
|
317
|
+
|
277
318
|
reader.close
|
278
319
|
end
|
279
320
|
|