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

Safe HaskellSafe
LanguageHaskell98

Data.Geolocation.GeoIP

Contents

Synopsis

Types

data GeoDB #

Type representing an established connection to a GeoIPCity database

combineOptions :: [GeoIPOption] -> GeoIPOption #

Collapse & combine multiple GeoIPOptions into one

Geolocation Result Type

Data Operations

openGeoDB :: GeoIPOption -> String -> IO GeoDB #

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) #

Geo-locate by given IP Adress

geoLocateByIPAddress db "123.123.123.123"

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

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

geoLocateByIPNum db 12336939327338

mkIpNum :: ByteString -> Maybe Integer #

Convert a string IP adress to IPNum