GeoIP2 is a haskell binding to the MaxMind GeoIP2 database.
It parses the database according to the MaxMind DB
specification,
version 2 of the specification is supported. The free geolite2 database can
be downloaded at http://dev.maxmind.com/geoip/geoip2/geolite2/.
See haddock documentaion for details.
{-# LANGUAGE OverloadedStrings #-}
import Data.GeoIP2
import Data.IP (IP(..))
main = do
geodb <- openGeoDB "GeoLite2-City.mmdb"
let ip = IPv4 "23.253.242.70"
print (findGeoData geodb "en" ip)
let ip2 = IPv6 "2001:4800:7817:104:be76:4eff:fe04:f608"
print (findGeoData geodb "en" ip2)
Changes
0.4.1.3
Allow pointers in header data
0.4.1.2
Fix autonomous_system decoding
0.4.1.1
Fix DataBool handling (#14)
0.4.1.0
Added domain field
0.4.0.1
Fixed typo
0.4.0.0
Added access to the complete parsed data
Added dependency on lens, exported some prisms for easy access
Small refactoring of functions, added more exports
0.3.0.1
Fix compiling with GHC 8.6.1
0.3.0.0
Include timezone and accuracy in location results
0.2.0.1
Fixed a problem with correct decoding of 28-bit offsets
0.2.0.0
Changed interface to normal Either String GeoResult
0.1.0.3 -> 0.1.0.4
Removed lru
Switched from binary to cereal with a significant speedup
0.1.0.2 -> 0.1.0.3
Changed bytestring-mmap to mmap
Add LRU caching to improve performance (10000 entries are cached)
0.1.0.1 -> 0.1.0.2
GHC-7.10 compatibiliy
Add Changelog.md
List Changelog.md and README.md in cabal’s extra-source-files