Javascript module for updating free Geo IP Maxmind binary databases (aka mmdb or geoip2). Based on Node.js EventEmitter, so that it can be combined with other Maxmind based modules.
Free GEO databases are available for download here.
npm i fmaxmind-updatervar ipDatabaseUpdater = require('fmaxmind-updater');
var ipDbUpdater = new ipDatabaseUpdater({
destFile: '/tmp/GeoLite2-Country.mmdb.gz',
md5url: 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.md5',
originFile: '/dbWillBeHere/GeoLite2-Country.mmdb',
timeout: 24*60*60*1000,
url: 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz'
});
ipDbUpdater.on('error', function(data){ console.log(new Date(), data) });
ipDbUpdater.on('notice', function(data){ console.log(new Date(), data) });
ipDbUpdater.on('update', function(data){ console.log(new Date(), data) }); //reload maxmind plugin on this event
ipDbUpdater.start();Initially get server hash which triggers all update process. Also set timeout to repeat this process.
var ipDatabaseUpdater = require('fmaxmind-updater');
var ipDbUpdater = new ipDatabaseUpdater();
ipDbUpdater.start();Clears timeout, i.e. prevents next server hash checking.
...
ipDbUpdater.stop();Emits following events:
- error
- notice
- update
Triggered when error occurs
var ipDatabaseUpdater = require('fmaxmind-updater');
var ipDbUpdater = new ipDatabaseUpdater();
ipDbUpdater.on('error', function(data){ console.log(new Date(), data) });Triggered when plugin has been started, stopped or database is up to date
var ipDatabaseUpdater = require('fmaxmind-updater');
var ipDbUpdater = new ipDatabaseUpdater();
ipDbUpdater.on('notice', function(data){ console.log(new Date(), data) });Triggered when database has been updated
var ipDatabaseUpdater = require('fmaxmind-updater');
var ipDbUpdater = new ipDatabaseUpdater();
ipDbUpdater.on('update', function(data){ console.log(new Date(), data) });Temporary file location which is used for downloading from server. Should have .gz extension.
var ipDbUpdater = new ipDatabaseUpdater({
...
destFile: '/tmp/GeoLite2-Country.mmdb.gz',
...
});Url for obtaining database md5 hash from maxmind server.
var ipDbUpdater = new ipDatabaseUpdater({
...
destFile: '/tmp/GeoLite2-Country.mmdb.gz',
...
});Path to file to be updated.
var ipDbUpdater = new ipDatabaseUpdater({
...
originFile: '/dbWillBeHere/GeoLite2-Country.mmdb',
...
});Checks for updates every 'timeout' milliseconds.
var ipDbUpdater = new ipDatabaseUpdater({
...
timeout: 24*60*60*1000,
...
});Url of gziped free database.
var ipDbUpdater = new ipDatabaseUpdater({
...
url: 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz',
...
});md5-file by linusu github repo
MIT