Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data GeoDB
- openGeoDB :: FilePath -> IO GeoDB
- geoDbLanguages :: GeoDB -> [Text]
- geoDbType :: GeoDB -> Text
- geoDbDescription :: GeoDB -> Maybe Text
- geoDbAddrType :: GeoDB -> GeoIP
- findGeoData :: Monad m => GeoDB -> Text -> IP -> m GeoResult
- data GeoResult = GeoResult {
- geoContinent :: Maybe Text
- geoContinentCode :: Maybe Text
- geoCountryISO :: Maybe Text
- geoCountry :: Maybe Text
- geoLocation :: Maybe (Double, Double)
- geoCity :: Maybe Text
- geoSubdivisions :: [(Text, Text)]
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
openGeoDB :: FilePath -> IO GeoDB Source
Open database, mmap it into memory, 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
Querying the database
:: Monad m | |
=> GeoDB | Db handle |
-> Text | Language code (e.g. "en") |
-> IP | IP address to search |
-> m GeoResult | Result, if something is found |
Search GeoIP database, monadic version (e.g. use with Maybe or Either)
Result of a search query
GeoResult | |
|