Packages
Adds geo location to a Plug connection based upon the client IP address by using MaxMind's GeoIP2 database.
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/update_geolite2.ex
defmodule Mix.Tasks.UpdateGeolite2 do
use Mix.Task
@shortdoc "Fetches the latest GeoLite2 DBs from MaxMind."
def run(_) do
File.rm('GeoLite2-City.mmdb.gz')
File.rm('GeoLite2-Country.mmdb.gz')
:inets.start
:httpc.request(:get, {'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', []}, [], [{:stream, 'GeoLite2-City.mmdb.gz'}])
:httpc.request(:get, {'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz', []}, [], [{:stream, 'GeoLite2-Country.mmdb.gz'}])
end
end