sapics / geoip-country

Less memory usage version of geoip-lite by supporting only country lookup.
Other
88 stars 13 forks source link

Make the database download URL configurable (e.g. via ENV variables) #25

Closed Zehelein closed 5 months ago

Zehelein commented 6 months ago

We are using the upgrade logic from your library to download the latest version of the Maxmind DB during application startup and once a day. But we have multiple service instances and sometimes multiple (deployment) restarts and ran into the Maxmind download limit. Therefor we would like to have some application download the Maxmind database to a local repository. And the applications would then not go anymore to Maxmind directly to download the DB but from the local repository.

Would it be possible to adjust your download script to allow the configuration of a different URL?

change https://github.com/sapics/geoip-country/blob/main/scripts/updatedb.js line 6 to something like this?

var download_server = process.env.geoip_download_url || 'https://download.maxmind.com/app/geoip_download';

Just in case - this is also suggested by Maxmind so it should be fine with their license (source):

**Every account is limited to 2,000 total direct downloads (30 for GeoLite accounts) in a 24-hour period. If you have to distribute your databases across multiple servers, it is advisable that you download databases to a local repository on your network, and distribute them to other servers from there.

Thanks

sapics commented 5 months ago

Thank you for your suggestion! It looks great! I fix the line 6 with env GEOLITE2_DOWNLOAD_URL. Could you try newer version?

Zehelein commented 5 months ago

Great - works like a charm - thanks 😃