geoip2 0.2.1.1 → 0.2.2.0
raw patch · 2 files changed
+10/−4 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.GeoIP2: openGeoDBBS :: ByteString -> IO GeoDB
Files
- Data/GeoIP2.hs +9/−3
- geoip2.cabal +1/−1
Data/GeoIP2.hs view
@@ -16,7 +16,7 @@ -- * Opening the database GeoDB- , openGeoDB+ , openGeoDB, openGeoDBBS , geoDbLanguages, geoDbType, geoDbDescription , geoDbAddrType, GeoIP(..) -- * Querying the database@@ -67,6 +67,14 @@ openGeoDB :: FilePath -> IO GeoDB openGeoDB geoFile = do bsmem <- mmapFileByteString geoFile Nothing+ parseGeoDB bsmem++-- | Open database from a bytestring, parse header and return a handle for search operations+openGeoDBBS :: BS.ByteString -> IO GeoDB+openGeoDBBS = parseGeoDB++parseGeoDB :: BS.ByteString -> IO GeoDB+parseGeoDB bsmem = do DataMap hdr <- either error return $ decode (getHeaderBytes bsmem) when (hdr .: "binary_format_major_version" /= (2 :: Int)) $ error "Unsupported database version, only v2 supported." unless (hdr .: "record_size" `elem` [24, 28, 32 :: Int]) $ error "Record size not supported."@@ -75,8 +83,6 @@ (hdr .: "node_count") (hdr .: "record_size") (if (hdr .: "ip_version") == (4 :: Int) then GeoIPv4 else GeoIPv6) (hdr .:? "description" ..? "en")-- rawGeoData :: GeoDB -> IP -> Either String GeoField rawGeoData geodb addr = do
geoip2.cabal view
@@ -1,5 +1,5 @@ name: geoip2-version: 0.2.1.1+version: 0.2.2.0 synopsis: Pure haskell interface to MaxMind GeoIP database description: GeoIP2 is a haskell binding to the MaxMind GeoIP2 database.