appliedsec / pygeoip

DEPRECATED: Pure Python API for Maxmind's binary GeoIP databases
https://github.com/appliedsec/pygeoip
GNU Lesser General Public License v3.0
482 stars 111 forks source link

Add support for MaxMind Netspeed #52

Closed tiwilliam closed 11 years ago

tiwilliam commented 11 years ago
>>> gi = pygeoip.GeoIP('/path/to/GeoIPNetSpeed.dat')
>>> gi.netspeed_by_name('google.com')
'Corporate'
>>> gi.id_by_name('google.com')
3
>>> gi.netspeed_by_name('defunct.cc')
'Cable'
oschwald commented 11 years ago

Do you support both Netspeed and NetspeedCell? They are unfortunately separate formats. The latter is the newer format and is more similar to the Org/ISP databases.

I noticed that some of your test databases are quite old (and large). There are some small unit test databases in the Java repo that you are free to use:

https://github.com/maxmind/geoip-api-java/tree/master/src/test/resources/GeoIP

If anything is missing from them, please let me know. The GeoIP-178 CSV corresponds to the NetspeedCell binary.

tiwilliam commented 11 years ago

This implementation was just for the first revision of Netspeed. I got really strange negative offsets when trying my Netspeed revision 1 database. I will try again with the Java databases, I got most of my databases from support@maxmind.com +1 year ago, a refresh would be nice. Thanks for your feedback!

oschwald commented 11 years ago

I haven't looked at the pygeoip code closely, but due to the format differences, you will likely need to use name_by_addr for the rev1 Netspeed databases instead of id_by_addr. This might be what is causing the offset errors.

Thanks for all of your work on the module!

oschwald commented 11 years ago

@tiwilliam, Would you be ok in licensing your unit tests under the LGPL 2.1 for use in the GeoIP extension? I ported them over to the extension before realizing that pygeoip is under the LGPL 3, not 2.1. From what I can tell, you are the sole author of the unit tests, but I could be mistaken. If not, I can rewrite them from scratch.

oschwald commented 11 years ago

Never mind, I see the tests were based off an earlier test file that was present when the repo was created. I'll just rewrite them.

tiwilliam commented 11 years ago

I guess me and @jennifere together own them, I can agree to change the license but we need @jennifere's voice on this.

oschwald commented 11 years ago

I ended up rewriting the tests from scratch rather than using the pygeoip one. Thanks though!