commit d3d8c70cac03f18610f74bb658ff8ff9535b8147 Author: David Kaloper david@numm.org Date: Mon Nov 4 05:56:45 2013 +0100
port to wheezy --- src/TorDNSEL/ExitTest/Request.hs | 1 - src/TorDNSEL/TorControl/Internals.hs | 9 +++++---- src/TorDNSEL/Util.hsc | 20 +++++++++++++------- tordnsel.cabal | 9 +++++---- 4 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/TorDNSEL/ExitTest/Request.hs b/src/TorDNSEL/ExitTest/Request.hs index affa6b8..5d74ae3 100644 --- a/src/TorDNSEL/ExitTest/Request.hs +++ b/src/TorDNSEL/ExitTest/Request.hs @@ -30,7 +30,6 @@ import Control.Arrow ((***)) import Control.Applicative import Control.Monad import Data.Monoid -import Data.Maybe import qualified Data.ByteString.Char8 as B import Data.Char (isSpace, toLower) import qualified Data.Map as M diff --git a/src/TorDNSEL/TorControl/Internals.hs b/src/TorDNSEL/TorControl/Internals.hs index 43b6d19..551593a 100644 --- a/src/TorDNSEL/TorControl/Internals.hs +++ b/src/TorDNSEL/TorControl/Internals.hs @@ -839,14 +839,13 @@ c_replies = c_lines_any =$= line0 []
line0 acc = await >>= return () `maybe` \line -> do let (code, (typ, text)) = B.splitAt 1 `second` B.splitAt 3 line - code' <- either (monadThrow . ProtocolError) return $ - parseReplyCode code + code' <- either throwProtoError return $ parseReplyCode code case () of _ | typ == B.pack "-" -> line0 (acc' []) | typ == B.pack "+" -> rest [] >>= line0 . acc' | typ == B.pack " " -> yield (reverse $ acc' []) >> line0 [] - | otherwise -> monadThrow $ - ProtocolError $ cat "Malformed reply line type " (esc 1 typ) '.' + | otherwise -> throwProtoError $ + cat "Malformed reply line type " (esc 1 typ) '.' where acc' xs = Reply code' text xs : acc
@@ -857,6 +856,8 @@ c_replies = c_lines_any =$= line0 [] | line == B.pack "." -> return $ reverse acc | otherwise -> rest (line:acc)
+ throwProtoError = lift . E.throw . ProtocolError + -------------------------------------------------------------------------------- -- Data types
diff --git a/src/TorDNSEL/Util.hsc b/src/TorDNSEL/Util.hsc index 7397208..12493fe 100644 --- a/src/TorDNSEL/Util.hsc +++ b/src/TorDNSEL/Util.hsc @@ -141,6 +141,7 @@ import System.Posix.Types (FileMode) import Text.Printf (printf) import Data.Binary (Binary(..))
+import Data.Conduit (Pipe(..), Conduit, Sink) import qualified Data.Conduit as C import qualified Data.Conduit.List as CL import qualified Data.Conduit.Binary as CB @@ -431,19 +432,25 @@ showUTCTime time = printf "%s %02d:%02d:%s" date hours mins secStr' -------------------------------------------------------------------------------- -- Conduit utilities
+-- ## Conduit 0.4.2 shim +-- ## +leftover :: Monad m => i -> Conduit i m o +leftover i = Done (Just i) () +-- ## + -- | 'CB.take' for strict 'ByteString's. -c_take :: Monad m => Int -> C.ConduitM ByteString o m ByteString +c_take :: Monad m => Int -> Sink ByteString m ByteString c_take = fmap (mconcat . BL.toChunks) . CB.take
-- | Read until the delimiter and return the parts before and after, not -- including delimiter. c_breakDelim :: Monad m => ByteString - -> C.ConduitM ByteString o m (Maybe (ByteString, ByteString)) + -> Sink ByteString m (Maybe (ByteString, ByteString)) c_breakDelim delim = wait_input $ B.empty where wait_input front = C.await >>= - (Nothing <$ C.leftover front) `maybe` \bs -> + (Nothing <$ leftover front) `maybe` \bs ->
let (front', bs') = (<> bs) `second` B.splitAt (B.length front - d_len + 1) front @@ -455,15 +462,14 @@ c_breakDelim delim = wait_input $ B.empty
d_len = B.length delim
- -- | Take a CRLF-delimited line from the input. -c_line_crlf :: Monad m => C.ConduitM ByteString o m ByteString +c_line_crlf :: Monad m => Sink ByteString m ByteString c_line_crlf = c_breakDelim (B.pack "\r\n") >>= - return B.empty `maybe` (line, rest) -> line <$ C.leftover rest + return B.empty `maybe` (line, rest) -> line <$ leftover rest
-- | Stream lines delimited by either LF or CRLF. -c_lines_any :: Monad m => C.Conduit ByteString m ByteString +c_lines_any :: Monad m => Conduit ByteString m ByteString c_lines_any = CB.lines C.=$= CL.map strip where strip bs = case unsnoc bs of diff --git a/tordnsel.cabal b/tordnsel.cabal index 827256e..0b5182c 100644 --- a/tordnsel.cabal +++ b/tordnsel.cabal @@ -13,10 +13,10 @@ Package-URL: https://archive.torproject.org/tor-package-archive/tordnsel/tor Author: tup Maintainer: tup.tuple@googlemail.com, lunar@debian.org, andrew@torproject.org Build-Type: Simple -Build-Depends: base>=2.0, network>=2.0, mtl>=1.0, unix>=1.0, stm>=2.0, - time>=1.0, HUnit>=1.1, binary>=0.4, bytestring>=0.9, array>=0.1, directory>=1.0, - containers>=0.1, conduit >= 1.0.0 && < 1.1.0, deepseq >= 1.3 -Tested-With: GHC==6.6, GHC==6.8, GHC==6.10, GHC==6.12 +Build-Depends: base>=4.5, network==2.3.*, mtl==2.*, unix>=2.5, stm>=2.3, + time>=1.4, HUnit>=1.2, binary>=0.5, bytestring>=0.9, array>=0.4, + directory>=1.1, containers>=0.4, conduit==0.4.2, deepseq>=1.3 +Tested-With: GHC==7.4, GHC==7.6 Data-Files: config/tordnsel.conf.sample, contrib/cacti-input.pl, contrib/tordnsel-init.d-script.sample, doc/tordnsel.8
@@ -72,6 +72,7 @@ Extensions: FlexibleContexts DeriveDataTypeable GeneralizedNewtypeDeriving Rank2Types + StandaloneDeriving
Executable: runtests Buildable: False
tor-commits@lists.torproject.org