Geolocation as a service
Haskell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
Main.hs
README.md
Setup.hs
geode.cabal
swagger.json

README.md

About

Geode is a simple Web frontend for MaxMind's GeoIP2 City database.

Setup

Purchase a GeoIP2 City database, or grab a free GeoLite2 City database from MaxMind:

$ curl -s http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz | \
  gunzip > GeoLite2-City.mmdb

Prep Cabal for building/running Geode:

$ cabal sandbox init
$ cabal install -j --only-dependencies

Usage

Fire up Geode:

$ GEOIP_DB=GeoLite2-City.mmdb cabal run
Running geode...
Setting phasers to stun... (port 3000) (ctrl-c to quit)

Try it out:

$ curl -s localhost:3000/8.8.8.8
{
  "regionName": "California",
  "latitude": 37.386,
  "postalCode": "94035",
  "city": "Mountain View",
  "countryName": "United States",
  "countryCode": "US",
  "region": "CA",
  "longitude": -122.0838,
  "continentCode": "NA",
  "continent": "North America"
}

If you make a request to / (leaving off any IP address) Geode will look up your IP address, checking for any X-Forwarded-For header, then falling back to the socket address of your client.