packages feed

inspection-proxy 0.1.0.1 → 0.1.0.2

raw patch · 2 files changed

+13/−14 lines, 2 filesdep ~asyncdep ~basedep ~bytestring

Dependency ranges changed: async, base, bytestring, cmdargs, pipes, pipes-network

Files

Main.hs view
@@ -1,14 +1,13 @@ module Main where  -    import Control.Proxy.TCP-    import Control.Proxy-    import System.Console.CmdArgs.Explicit--    import Control.Monad (void, unless, when)+    import Control.Monad (void, unless, when, forever)     import Data.Maybe (isNothing)     import Control.Concurrent.Async (async)     import qualified Data.ByteString.Char8 as B+    import Pipes+    import Pipes.Network.TCP+    import System.Console.CmdArgs.Explicit       arguments :: Mode [(String,String)]@@ -26,11 +25,11 @@                              | otherwise       = Just (snd $ as' !! 2, snd $ as' !! 1, snd $ head as')  -- arguments are parsed in reverse order  -    printPass :: Proxy p => Bool -> () -> p () B.ByteString b' B.ByteString IO r-    printPass skip () = runIdentityP $ forever $ do-        readValue <- request ()+    printPass :: Bool -> Pipe B.ByteString B.ByteString IO r+    printPass skip = forever $ do+        readValue <- await         unless skip $ lift $ B.putStrLn readValue-        void $ respond readValue+        yield readValue       main :: IO ()@@ -38,13 +37,13 @@         args <- processArgs arguments          let connectionDetails = proxyDetails args         let hasFlag flag      = (flag, "") `elem` args-        when (hasFlag "version") $ putStrLn "inspection-proxy version 0.1.0.0"+        when (hasFlag "version") $ putStrLn "inspection-proxy version 0.1.0.2"         if hasFlag "help" || isNothing connectionDetails             then print $ helpText [] HelpFormatDefault arguments             else do                 let Just (bindport, host, port) = connectionDetails                 serve HostAny bindport $ \(bindSocket, _) ->                      connect host port $ \(serviceSocket, _) -> do-                        void $ async $ runProxy $ socketReadS 4096 bindSocket >-> printPass (hasFlag "only-server") >-> socketWriteD serviceSocket -                        runProxy $ socketReadS 4096 serviceSocket >-> printPass (hasFlag "only-client") >-> socketWriteD bindSocket +                        void $ async $ runEffect $ fromSocket bindSocket 4096 >-> printPass (hasFlag "only-server") >-> toSocket serviceSocket +                        runEffect $ fromSocket serviceSocket 4096 >-> printPass (hasFlag "only-client") >-> toSocket bindSocket                  return ()
inspection-proxy.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                inspection-proxy-version:             0.1.0.1+version:             0.1.0.2 synopsis:            A simple proxy for debugging plaintext protocols communication description:         A command line utility to be launched as an intermediary plaintext service (http, memcache, etc) for easy inspection and debugging license:             OtherLicense@@ -22,4 +22,4 @@   main-is:             Main.hs   ghc-options:         -Wall -threaded -O3   -- other-modules:       -  build-depends:       base >=4.5 && <=4.6.0.1, pipes-network <=0.4, pipes ==3.2.0, bytestring >=0.9, async >=2.0, cmdargs >=0.10+  build-depends:       base ==4.*, pipes-network >= 0.6, pipes >= 4.0, bytestring, async, cmdargs