hs-GeoIP-0.3: Haskell bindings to the MaxMind GeoIPCity database via the C library

Safe HaskellNone

Data.Geolocation.GeoIP

Contents

Synopsis

Types

data GeoDB Source

Type representing an established connection to a GeoIPCity database

combineOptions :: [GeoIPOption] -> GeoIPOptionSource

Collapse & combine multiple GeoIPOptions into one

Geolocation Result Type

Data Operations

openGeoDB :: GeoIPOption -> String -> IO GeoDBSource

Open the binary GeoIP data file with the given options.

This would open a file and cache in memory:

 openGeoDB "GeoCity.dat" memory_cache

The memory on the C side is automatically freed by the Haskell GC when appropriate.

geoLocateByIPAddress :: GeoDB -> ByteString -> IO (Maybe GeoIPRecord)Source

Geo-locate by given IP Adress

 geoLocateByIPAddress db "123.123.123.123"

geoLocateByIPNum :: GeoDB -> Integer -> IO (Maybe GeoIPRecord)Source

Geo-locate by given IP number. Call mkIpNum on a String ip address to convert to IP number.

 geoLocateByIPNum db 12336939327338

mkIpNum :: ByteString -> Maybe IntegerSource

Convert a string IP adress to IPNum