geoip2 0.4.0.1 → 0.4.1.0
raw patch · 3 files changed
+11/−6 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.GeoIP2: [geoDomain] :: GeoResult -> Maybe Text
- Data.GeoIP2: GeoResult :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Location -> Maybe Text -> Maybe Int -> Maybe Text -> Maybe AS -> Maybe Text -> Maybe Text -> Maybe Text -> [(Text, Text)] -> GeoResult
+ Data.GeoIP2: GeoResult :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Location -> Maybe Text -> Maybe Int -> Maybe Text -> Maybe AS -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> [(Text, Text)] -> GeoResult
- Data.GeoIP2: _DataArray :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) [GeoFieldT a_a7I1]
+ Data.GeoIP2: _DataArray :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) [GeoFieldT a_a6NN]
- Data.GeoIP2: _DataBool :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) Bool
+ Data.GeoIP2: _DataBool :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) Bool
- Data.GeoIP2: _DataDouble :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) Double
+ Data.GeoIP2: _DataDouble :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) Double
- Data.GeoIP2: _DataInt :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) Int64
+ Data.GeoIP2: _DataInt :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) Int64
- Data.GeoIP2: _DataMap :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) (Map (GeoFieldT a_a7I1) (GeoFieldT a_a7I1))
+ Data.GeoIP2: _DataMap :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) (Map (GeoFieldT a_a6NN) (GeoFieldT a_a6NN))
- Data.GeoIP2: _DataString :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) Text
+ Data.GeoIP2: _DataString :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) Text
- Data.GeoIP2: _DataUnknown :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) (Word8, Int64)
+ Data.GeoIP2: _DataUnknown :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) (Word8, Int64)
- Data.GeoIP2: _DataWord :: forall a_a7I1. Prism' (GeoFieldT a_a7I1) Word64
+ Data.GeoIP2: _DataWord :: forall a_a6NN. Prism' (GeoFieldT a_a6NN) Word64
Files
- ChangeLog.md +3/−0
- Data/GeoIP2.hs +7/−5
- geoip2.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,6 @@+# 0.4.1.0+- Added domain field+ # 0.4.0.1 - Fixed typo
Data/GeoIP2.hs view
@@ -30,7 +30,7 @@ -- * Internals , GeoField, GeoFieldT(..) , rawGeoData- -- * Lenses + -- * Lenses , _DataString, _DataDouble, _DataInt, _DataWord , _DataMap, _DataArray, _DataBool, _DataUnknown , key@@ -92,7 +92,7 @@ openGeoDBBS :: BS.ByteString -> Either String GeoDB openGeoDBBS bsmem = do hdr <- decode (getHeaderBytes bsmem)- when (hdr ^? key "binary_format_major_version" . geoNum /= (Just 2 :: Maybe Int)) $ + when (hdr ^? key "binary_format_major_version" . geoNum /= (Just 2 :: Maybe Int)) $ Left "Unsupported database version, only v2 supported." unless (hdr ^? key "record_size" . geoNum `elem` (Just <$> [24, 28, 32 :: Int])) $ Left "Record size not supported."@@ -114,7 +114,7 @@ pto 6 = Just GeoIPv6 pto _ = Nothing --- | Search GeoIP database and return complete unparsed data +-- | Search GeoIP database and return complete unparsed data rawGeoData :: GeoDB -> IP -> Either String GeoField rawGeoData geodb addr = do bits <- coerceAddr@@ -123,12 +123,12 @@ where dataSectionStart = (geoDbRecordSize geodb `div` 4) * fromIntegral (geoDbNodeCount geodb) + 16 dataSection = BS.drop dataSectionStart (geoMem geodb)- + strictDataAt :: Int64 -> Either String GeoField strictDataAt offset = do raw <- decode (BS.drop (fromIntegral offset) dataSection) traversePtr (strictDataAt . fromIntegral) raw- + coerceAddr | (IPv4 _) <- addr, GeoIPv4 <- geoDbAddrType geodb = return $ ipToBits addr | (IPv6 _) <- addr, GeoIPv6 <- geoDbAddrType geodb = return $ ipToBits addr@@ -153,6 +153,7 @@ , geoPostalCode :: Maybe T.Text , geoAS :: Maybe AS , geoISP :: Maybe T.Text+ , geoDomain :: Maybe T.Text , geoOrganization :: Maybe T.Text , geoUserType :: Maybe T.Text , geoSubdivisions :: [(T.Text, T.Text)]@@ -194,6 +195,7 @@ , geoAS = AS <$> res ^? key "traits" . key "autonomous_system_number" . geoNum <*> res ^? key "traits" . key "autonomous_system_organization" . _DataString , geoISP = res ^? key "traits" . key "isp" . _DataString+ , geoDomain = res ^? key "traits" . key "domain" . _DataString , geoOrganization = res ^? key "traits" . key "organization" . _DataString , geoUserType = res ^? key "traits" . key "user_type" . _DataString , geoSubdivisions = subdivs
geoip2.cabal view
@@ -1,5 +1,5 @@ name: geoip2-version: 0.4.0.1+version: 0.4.1.0 synopsis: Pure haskell interface to MaxMind GeoIP database description: GeoIP2 is a haskell binding to the MaxMind GeoIP2 database.