rabuchaim / geoip2fast

GeoIP2Fast is the fastest GeoIP2 country/city/asn lookup library. A search takes less than 0.00003 seconds. It has its own data file updated twice a week with Maxmind-Geolite2-CSV and is Pure Python!
https://pypi.org/project/geoip2fast/
MIT License
34 stars 3 forks source link

Coverage is greater than 100% with Maxmind CSV files from 2023-10-17 #6

Closed rabuchaim closed 8 months ago

rabuchaim commented 8 months ago

Coverage is greater than 100% with Maxmind CSV files from 2023-10-17

Possible a duplicated network inside CSV files.

# geoip2fast --coverage
GeoIP2Fast v1.1.1 is ready! geoip2fast.dat.gz loaded with 451849 networks in 0.03863 seconds and using 24.78 MiB.

Use the parameter '-v' to see all networks included in your /usr/local/lib/python3.10/dist-packages/geoip2fast/geoip2fast.dat.gz file.

Current IPv4 coverage: 100.04% (4,296,574,623 IPv4 in 451849 networks) [0.08265 sec]
Current IPv6 coverage: 0.000000000% (0 IPv6 in 0 networks) [0.08270 sec]

Requires a detailed check and a function that prevents entering duplicate networks. Currently, geoip2dat.py generates dat files from what is contained in the Maxmind files and does not check for network duplicity.

The coverage calculation lists all included networks, calculates how many IPs there are in each network, sum up these IPs and compares them with the maximum possible IPv4, which is 4294967296 IPs.

This does not affect search accuracy.

rabuchaim commented 8 months ago

The calculation is correct and no duplicate networks were found in the CSV file.

The problem occurs on the IPv6 network that was inserted in the reserverNetworks variable.

"fd00::/8": {"15":"Reserved for Unique Local Addresses"}

This network is being considered in calculations even for IPv4 and it should not be.

It will be fixed in the next version. And this does not impact search accuracy, since IPv6 converted to integer is much larger than any IPv4 in integer.

In the CSV of 2023-10-17 we have the highest GeoIP coverage ever recorded since the launch of GeoIP2Fast, we have 99.65% coverage!

[DEBUG] - Country IP coverage 99.65%

In short:

rabuchaim commented 8 months ago

Fixed in version v1.1.3