From 498551c1e0e115a353079919fa6abab3e939ae41 Mon Sep 17 00:00:00 2001 From: Rama McIntosh Date: Tue, 30 Apr 2024 19:56:31 -1000 Subject: [PATCH 1/4] series option to support GeoIP2 premium database --- scripts/updatedb.js | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/scripts/updatedb.js b/scripts/updatedb.js index a8738225..8aa436e9 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -37,6 +37,17 @@ var geodatadir = args.find(function(arg) { if (typeof geodatadir === 'undefined' && typeof process.env.GEODATADIR !== 'undefined') { geodatadir = 'geodatadir='+process.env.GEODATADIR; } +var series = args.find(function(arg) { + return arg.match(/^series=[\w./]+/) !== null; +}); +if (typeof series === 'undefined' && typeof process.env.GEODBSERIES !== 'undefined') { + series = process.env.GEODBSERIES; +} else if (typeof series !== 'undefined') { + series = series.slice('series='.length); +} +if (typeof series === 'undefined') { + series = 'GeoLite2' +} var dataPath = path.resolve(__dirname, '..', 'data'); if (typeof geodatadir !== 'undefined') { dataPath = path.resolve(process.cwd(), geodatadir.split('=')[1]); @@ -51,13 +62,13 @@ var cityLookup = {NaN: -1}; var databases = [ { type: 'country', - url: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&suffix=zip&'+license_key, - checksum: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&suffix=zip.sha256&'+license_key, - fileName: 'GeoLite2-Country-CSV.zip', + url: 'https://download.maxmind.com/app/geoip_download?edition_id='+series+'-Country-CSV&suffix=zip&'+license_key, + checksum: 'https://download.maxmind.com/app/geoip_download?edition_id='+series+'-Country-CSV&suffix=zip.sha256&'+license_key, + fileName: series+'-Country-CSV.zip', src: [ - 'GeoLite2-Country-Locations-en.csv', - 'GeoLite2-Country-Blocks-IPv4.csv', - 'GeoLite2-Country-Blocks-IPv6.csv' + series+'-Country-Locations-en.csv', + series+'-Country-Blocks-IPv4.csv', + series+'-Country-Blocks-IPv6.csv' ], dest: [ '', @@ -67,13 +78,13 @@ var databases = [ }, { type: 'city', - url: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City-CSV&suffix=zip&'+license_key, - checksum: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City-CSV&suffix=zip.sha256&'+license_key, - fileName: 'GeoLite2-City-CSV.zip', + url: 'https://download.maxmind.com/app/geoip_download?edition_id='+series+'-City-CSV&suffix=zip&'+license_key, + checksum: 'https://download.maxmind.com/app/geoip_download?edition_id='+series+'-City-CSV&suffix=zip.sha256&'+license_key, + fileName: series+'-City-CSV.zip', src: [ - 'GeoLite2-City-Locations-en.csv', - 'GeoLite2-City-Blocks-IPv4.csv', - 'GeoLite2-City-Blocks-IPv6.csv' + series+'-City-Locations-en.csv', + series+'-City-Blocks-IPv4.csv', + series+'-City-Blocks-IPv6.csv' ], dest: [ 'geoip-city-names.dat', From 17f0d67d51483d0665725609a8adb7bab92313cf Mon Sep 17 00:00:00 2001 From: Rama McIntosh Date: Tue, 30 Apr 2024 20:15:53 -1000 Subject: [PATCH 2/4] update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cd88f5b5..a3ed8b31 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ Run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICE You can create a maxmind account [here](https://www.maxmind.com/en/geolite2/signup) +Maxmind also sells subscriptions to premium and more accurate data. With a subscritpions the files can be updated with `series` option. Run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY series=GeoIP2` to update the data files with the premium more accureate data sets. + **NOTE** that this requires a lot of RAM. It is known to fail on on a Digital Ocean or AWS micro instance. There are no plans to change this. `geoip-lite` stores all data in RAM in order to be fast. From 2bf77916772f129dd7315ccaefac61a95ea701c6 Mon Sep 17 00:00:00 2001 From: Rama McIntosh Date: Tue, 30 Apr 2024 20:19:03 -1000 Subject: [PATCH 3/4] mc to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3ed8b31..c9642304 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICE You can create a maxmind account [here](https://www.maxmind.com/en/geolite2/signup) -Maxmind also sells subscriptions to premium and more accurate data. With a subscritpions the files can be updated with `series` option. Run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY series=GeoIP2` to update the data files with the premium more accureate data sets. +Maxmind also sells subscriptions to premium and more accurate data. With a subscritpions the files can be updated with the `series` option. With a license key with a premium subscription, run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY series=GeoIP2` to update the data files with the premium more accureate data sets. **NOTE** that this requires a lot of RAM. It is known to fail on on a Digital Ocean or AWS micro instance. There are no plans to change this. `geoip-lite` stores all data in RAM in order to be fast. From 9d9a335d6692cf04c1c9b6a17560c64d55eaab1c Mon Sep 17 00:00:00 2001 From: Rama McIntosh Date: Tue, 30 Apr 2024 20:19:50 -1000 Subject: [PATCH 4/4] mc in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9642304..54aa0727 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICE You can create a maxmind account [here](https://www.maxmind.com/en/geolite2/signup) -Maxmind also sells subscriptions to premium and more accurate data. With a subscritpions the files can be updated with the `series` option. With a license key with a premium subscription, run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY series=GeoIP2` to update the data files with the premium more accureate data sets. +Maxmind also sells subscriptions to premium and more accurate data. With a subscritpion the files can be updated with the `series` option. With a license key with a premium subscription, run `cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY series=GeoIP2` to update the data files with the premium more accureate data sets. **NOTE** that this requires a lot of RAM. It is known to fail on on a Digital Ocean or AWS micro instance. There are no plans to change this. `geoip-lite` stores all data in RAM in order to be fast.