Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data GeoDB
- openGeoDB :: FilePath -> IO GeoDB
- openGeoDBBS :: ByteString -> IO GeoDB
- geoDbLanguages :: GeoDB -> [Text]
- geoDbType :: GeoDB -> Text
- geoDbDescription :: GeoDB -> Maybe Text
- geoDbAddrType :: GeoDB -> GeoIP
- data GeoIP
- findGeoData :: GeoDB -> Text -> IP -> Either String GeoResult
- data GeoResult = GeoResult {
- geoContinent :: Maybe Text
- geoContinentCode :: Maybe Text
- geoCountryISO :: Maybe Text
- geoCountry :: Maybe Text
- geoLocation :: Maybe (Double, Double)
- geoCity :: Maybe Text
- geoPostalCode :: 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
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
geoDbAddrType :: GeoDB -> GeoIP Source #
Type of address (IPv4/IPv6) stored in a database
Address type stored in database
Querying the database
:: 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
Result of a search query
GeoResult | |
|