maxmind / mod_maxminddb

MaxMind DB Apache Module
https://maxmind.github.io/mod_maxminddb/
Apache License 2.0
126 stars 28 forks source link

access network field from GeoLite2-ASN.mmdb #81

Closed darix closed 4 years ago

darix commented 5 years ago

The following ruby script

require 'maxminddb'
db = MaxMindDB.new('GeoLite2-ASN.mmdb')
p db.lookup('1.1.1.1')

gives me this output (reformatted for readability):

#<MaxMindDB::Result:0x000055a27cd962b8
  @raw={
    "autonomous_system_number"=>13335,
    "autonomous_system_organization"=>"Cloudflare, Inc.",
    "network"=>"1.1.1.0/24"
  }>

How to access the "network" field from within mod_maxminddb? Are the ruby bindings just exposing this by accident? I just noticed the python bindings aren't exposing it.

It would be really helpful to replace mod_asn with mod_maxminddb.

oschwald commented 5 years ago

This is not currently available in mod_maxminddb or the library it uses. It is feature specific to the third-party Ruby API you are using.

darix commented 5 years ago

How much work would it be to fix that for the library? Should I open a bug there as well?

darix commented 5 years ago

I guess one option would be to generate a custom ASN mmdb file based on the CSV and then expose the subnet in another field?

oschwald commented 5 years ago

You could generate such an mmdb file. It would likely end up being fairly large as it wouldn't be able to deduplicate the records.

Adding support for retrieving the network is something we are considering for some of our APIs. You could open a bug against libmaxminddb as well, if there isn't one, as that would need to be updated first.

oschwald commented 4 years ago

This was done in #82. We have not done a release with it yet though.