geoip2-0.2.2.0: Pure haskell interface to MaxMind GeoIP database

Safe HaskellNone
LanguageHaskell2010

Data.GeoIP2

Contents

Synopsis

Library description

A haskell library for reading MaxMind's GeoIP version 2 files. It supports both IPv4 and IPv6 addresses. When a match is found, it is parsed and a simplified structure is returned. If you want to access other fields than those that are exposed, it is internally possible.

The database is mmapped upon opening, all querying can be later performed purely without IO monad.

Opening the database

data GeoDB Source #

Handle for search operations

openGeoDB :: FilePath -> IO GeoDB Source #

Open database, mmap it into memory, parse header and return a handle for search operations

openGeoDBBS :: ByteString -> IO GeoDB Source #

Open database from a bytestring, parse header and return a handle for search operations

geoDbLanguages :: GeoDB -> [Text] Source #

Languages supported in database

geoDbType :: GeoDB -> Text Source #

String that indicates the structure of each data record associated with an IP address

geoDbDescription :: GeoDB -> Maybe Text Source #

Description of a database in english

geoDbAddrType :: GeoDB -> GeoIP Source #

Type of address (IPv4/IPv6) stored in a database

data GeoIP Source #

Address type stored in database

Constructors

GeoIPv6 
GeoIPv4 

Instances

Eq GeoIP Source # 

Methods

(==) :: GeoIP -> GeoIP -> Bool #

(/=) :: GeoIP -> GeoIP -> Bool #

Show GeoIP Source # 

Methods

showsPrec :: Int -> GeoIP -> ShowS #

show :: GeoIP -> String #

showList :: [GeoIP] -> ShowS #

Querying the database

findGeoData Source #

Arguments

:: GeoDB

Db handle

-> Text

Language code (e.g. "en")

-> IP

IP address to search

-> Either String GeoResult

Result, if something is found

Search GeoIP database