IPv6DB 0.3.2 → 0.3.3
raw patch · 7 files changed
+42/−45 lines, 7 filesdep ~IPv6Addrdep ~aesondep ~attoparsecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: IPv6Addr, aeson, attoparsec, bytestring, hedis, hspec, http-client, text, unordered-containers
API changes (from Hackage documentation)
Files
- IPv6DB.cabal +20/−20
- README.md +2/−2
- app/Main.hs +2/−4
- app/Options.hs +1/−2
- app/Queries.hs +12/−12
- app/Types.hs +1/−1
- src/Network/IPv6DB/Types.hs +4/−4
IPv6DB.cabal view
@@ -1,23 +1,23 @@ name: IPv6DB-version: 0.3.2+version: 0.3.3 synopsis: A RESTful microService for IPv6-related data description: IPv6DB is a RESTful microservice using Redis as backend to store lists of IPv6 addresses and attach to each of them any valuable data in a schema-free valid JSON value. Each resource can be permanent or TTLed.-homepage: http://ipv6db.cybervisible.com+homepage: http://ipv6db.functor.cloud license: BSD3 license-file: LICENSE author: Michel Boucey maintainer: michel.boucey@gmail.com-copyright: (c) 2017-2020 - Michel Boucey+copyright: (c) 2017-2022 - Michel Boucey category: network, database build-type: Simple cabal-version: >=1.10 extra-source-files: README.md , IPv6DB_APIv1.md -Tested-With: GHC ==8.4.3 || ==8.6.5 || ==8.8.1+Tested-With: GHC == 9.2.1 Source-Repository head Type: git@@ -26,16 +26,16 @@ library hs-source-dirs: src exposed-modules: Network.IPv6DB.Types - build-depends: aeson >= 0.11.2 && < 1.5- , attoparsec >= 0.13.1.0 && < 0.14+ build-depends: aeson == 2.0.*+ , attoparsec >= 0.13.1.0 && < 0.15 , base >= 4.8.2 && < 5.0- , bytestring >= 0.10.6 && < 0.11- , IPv6Addr >= 1.1.0 && < 1.2.0- , hedis >= 0.9.4 && < 0.13+ , bytestring == 0.11.*+ , IPv6Addr >= 2.0 && < 2.1+ , hedis == 0.15.* , http-types >= 0.9.1 && < 0.13- , unordered-containers >= 0.2.7.2 && < 0.2.11+ , unordered-containers >= 0.2.7 && < 0.3 , mtl >= 2.2.1 && < 2.3- , text >= 1.2.2 && < 1.3+ , text >= 1.2.5.0 && < 2.1 , vector >= 0.11.0.0 && < 0.13 default-language: Haskell2010 @@ -45,18 +45,18 @@ other-modules: Options , Queries , Types- build-depends: aeson >= 0.11.2 && < 1.5+ build-depends: aeson == 2.0.* , base >= 4.8.2 && < 5.0- , bytestring >= 0.10.6 && < 0.11+ , bytestring >= 0.10 && < 0.12 , fast-logger >= 2.4.8 && < 3.1- , IPv6Addr >= 1.1.3 && < 1.2.0+ , IPv6Addr >= 2.0 && < 2.1 , IPv6DB- , hedis >= 0.9.4 && < 0.13+ , hedis == 0.15.* , http-types >= 0.9.1 && < 0.13- , unordered-containers >= 0.2.7.2 && < 0.2.11+ , unordered-containers >= 0.2.7 && < 0.3 , mtl >= 2.2.1 && < 2.3 , optparse-applicative >= 0.12.1.0 && < 0.16- , text >= 1.2.2 && < 1.3+ , text >= 1.2.5.0 && < 2.1 , vector >= 0.11.0.0 && < 0.13 , wai >= 3.2.1 && < 3.3 , wai-logger >= 2.2.7 && < 2.4@@ -69,12 +69,12 @@ type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: hspec.hs- build-depends: aeson >= 0.11.2 && < 1.5- , hspec >= 2.1.10 && < 2.6+ build-depends: aeson == 2.0.*+ , hspec >= 2.1.10 && < 2.8 , base >= 4.8.2 && < 5 , IPv6DB , vector >= 0.11.0.0 && < 0.13- , http-client >= 0.4.31.2 && < 0.6+ , http-client == 0.7.* , http-types >= 0.9.1 && < 0.13 default-language: Haskell2010
README.md view
@@ -1,12 +1,12 @@ # IPv6DB -## A RESTful Web service for IPv6 related data [](https://travis-ci.org/MichelBoucey/IPv6DB)+## A RESTful Web service for IPv6 related data  IPv6DB is a RESTful microservice using Redis as backend to store lists of IPv6 addresses and attach to each of them any valuable data in a schema-free valid JSON value. Each resource can be permanent or TTLed. ```bash [user@box ~]$ ipv6db --help-IPv6DB v0.2.0 APIv1, (c) Michel Boucey 2017+IPv6DB v0.3.3 APIv1, (c) Michel Boucey 2017-2022 Usage: ipv6db [-h|--host ARG] [-p|--port ARG] [-l|--log-file ARG] [-o|--redis-host ARG] [-r|--redis-port ARG]
app/Main.hs view
@@ -1,15 +1,13 @@ {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} -import Control.Monad.IO.Class (liftIO) import Control.Monad.Reader import Data.Aeson as A import qualified Data.ByteString.Lazy as BSL import Data.Maybe (fromJust)-import Data.Monoid ((<>)) import Data.String (fromString) import qualified Data.Vector as V import Database.Redis hiding (String)@@ -96,7 +94,7 @@ answer ents = runRedis redisConn (getByEntries ents) >>= \case Right srcs -> withEnv env (fromEntries ents srcs) >>= jsonOk- Left _ -> jsonError "Backend Error"+ Left _ -> jsonError "Backend Error" DELETE -> maybeJSONBody >>= maybe badJSONRequest answer where
app/Options.hs view
@@ -2,7 +2,6 @@ module Options where import Data.ByteString-import Data.Monoid ((<>)) import Options.Applicative data Options =@@ -20,7 +19,7 @@ opts = info (options <**> helper) ( fullDesc <> progDesc "RESTful Web Service for IPv6 related data"- <> header "IPv6DB v0.3.1 APIv1, (c) Michel Boucey 2017-2018" )+ <> header "IPv6DB v0.3.3 APIv1, (c) Michel Boucey 2017-2022" ) options :: Parser Options options =
app/Queries.hs view
@@ -1,17 +1,17 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-} module Queries where -import Control.Monad (zipWithM) import Control.Monad.Reader import Data.Aeson as A+import qualified Data.Aeson.KeyMap as KM import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL-import Data.HashMap.Lazy+import Data.HashMap.Lazy (fromList) import Data.Maybe (fromJust)-import Data.Monoid ((<>)) import qualified Data.Text as T import Data.Text.Encoding import Database.Redis as R hiding (decode)@@ -61,7 +61,7 @@ setSource _ _ ResourceError{} = undefined setSource conn mtd Resource{ttl=ttlr,..} = do er <- runRedis conn $ setOpts- (toKey list $ fromIPv6Addr address)+ (toKey list $ unIPv6Addr address) (BSL.toStrict $ encode source) SetOpts { setSeconds = ttlr@@ -164,10 +164,10 @@ case v of Object hm -> do let hm' =- if member "ttl" hm+ if KM.member "ttl" hm then hm- else insert "ttl" Null hm- case fromJSON (Object $ union hm' $ fromList prs) of+ else KM.insert "ttl" Null hm+ case fromJSON (Object $ KM.union hm' $ KM.fromHashMapText $ fromList prs) of A.Success r -> Just r A.Error _ -> Nothing _ -> Nothing@@ -199,11 +199,11 @@ -> Addresses -> [BS.ByteString] addressesToKeys list (Addresses addrs) =- toKey list . fromIPv6Addr <$> addrs+ toKey list . unIPv6Addr <$> addrs fromEnts :: Entries -> [BS.ByteString] fromEnts (Entries ents) =- (\Entry{..} -> toKey list (fromIPv6Addr address)) <$> ents+ (\Entry{..} -> toKey list (unIPv6Addr address)) <$> ents toEntry :: T.Text -> IPv6Addr -> Entry toEntry list address = Entry { list = list, address = address }
app/Types.hs view
@@ -4,11 +4,11 @@ module Types where -import Database.Redis import Data.Aeson as A import qualified Data.ByteString as BS import Data.Text.Encoding import qualified Data.Vector as V+import Database.Redis import Prelude hiding (error) import Network.IPv6DB.Types
src/Network/IPv6DB/Types.hs view
@@ -4,9 +4,9 @@ module Network.IPv6DB.Types where -import Data.Aeson as A-import qualified Data.Text as T-import qualified Data.Vector as V+import Data.Aeson as A+import qualified Data.Text as T+import qualified Data.Vector as V import Text.IPv6Addr newtype Addresses = Addresses [IPv6Addr]@@ -61,7 +61,7 @@ { list :: !T.Text , address :: !IPv6Addr , error :: !T.Text- } + } deriving (Eq, Show) instance ToJSON Resource where