geoip-lite / node-geoip

Native NodeJS implementation of MaxMind's GeoIP API -- works in node 0.6.3 and above, ask me about other versions
https://npmjs.org/package/geoip-lite
Other
2.33k stars 359 forks source link

conversion tool #136

Open benmonro opened 6 years ago

benmonro commented 6 years ago

I've paid for the maxmind database. is there any documentation on how to use the conversion tool i keep reading about? I have the DB files, how do i now convert them so geoip-lite will be able to use them?

bluesmoon commented 6 years ago

So the conversion tool has evolved a bit to do the downloading and converting as one job. It's called updatedb here: https://github.com/bluesmoon/node-geoip/blob/master/scripts/updatedb.js

You'll want to edit it, and modify the URLs to the paid versions that you have access to on MaxMind's servers, but if you're a javascript programmer, you could just as well edit the script to accept pre-fetched DB files, and skip the fetch call at line 441

If you'd like to submit a patch for this, I'll merge it in.

konklone commented 5 years ago

I went about it something like this:

konklone commented 5 years ago

I only used the paid files at the country-level, but needed to download the free City level files to have something to work with, so here's what my updatedb.js file looked like, in defining the database object at the top:

var databases = [
    {
        type: 'country',
        url: 'http://localhost:5000/GeoIP2-Country-CSV_20181218.zip',
        src: [
            'GeoIP2-Country-Locations-en.csv',
            'GeoIP2-Country-Blocks-IPv4.csv',
            'GeoIP2-Country-Blocks-IPv6.csv'
        ],
        dest: [
            '',
            'geoip-country.dat',
            'geoip-country6.dat'
        ]
    },
    {
        type: 'city',
        url: 'http://localhost:5000/GeoLite2-City-CSV_20181218.zip',
        src: [
            'GeoLite2-City-Locations-en.csv',
            'GeoLite2-City-Blocks-IPv4.csv',
            'GeoLite2-City-Blocks-IPv6.csv'
        ],
        dest: [
            'geoip-city-names.dat',
            'geoip-city.dat',
            'geoip-city6.dat'
        ]
    }
];
ar2rsawseen commented 5 years ago

Is the format the same for paid files? Only the place where they can be fetched is different?

bluesmoon commented 5 years ago

yes