packages feed

network-conduit-tls 1.0.0.3 → 1.0.1

raw patch · 2 files changed

+29/−13 lines, 2 files

Files

Data/Conduit/Network/TLS.hs view
@@ -9,6 +9,7 @@     , tlsCertificate     , tlsKey     , tlsNeedLocalAddr+    , tlsAppData     , runTCPServerTLS     ) where @@ -30,7 +31,7 @@ import Data.Conduit (($$), yield) import qualified Data.Conduit.List as CL import Data.Either (rights)-import Network.Socket (sClose, getSocketName)+import Network.Socket (sClose, getSocketName, SockAddr) import Network.Socket.ByteString (recv, sendAll) import Control.Exception (bracket, finally) import Control.Concurrent (forkIO)@@ -97,17 +98,7 @@              TLS.handshake ctx -            let ad = AppData-                    { appSource =-                        let src = lift (TLS.recvData ctx) >>= yield >> src-                         in src-                    , appSink = CL.mapM_ $ TLS.sendData ctx . L.fromChunks . return-                    , appSockAddr = addr-                    , appLocalAddr = mlocal-                    }---            app ad `finally` sClose socket+            app (tlsAppData ctx addr mlocal) `finally` sClose socket          params = #if MIN_VERSION_tls(1, 0, 0)@@ -126,6 +117,31 @@             , TLS.pCertificates    = zip certs $ Just key : repeat Nothing             } #endif++-- | Create an @AppData@ from an existing tls @Context@ value. This is a lower level function, allowing you to create a connection in any way you want.+--+-- Sample usage:+--+-- > import Network.Simple.TCP.TLS+-- >+-- > myapp :: Application IO+-- > ...+-- > main = do+-- >     cset <- getDefaultClientSettings+-- >     connect cset "host" "port" $+-- >         (\(ctx, addr) -> myapp $ tlsAppData ctx addr Nothing)+--+-- Since 1.0.1+tlsAppData :: TLS.Context       -- ^ a TLS context+           -> SockAddr          -- ^ remote address+           -> Maybe SockAddr    -- ^ local address+           -> AppData IO+tlsAppData ctx addr mlocal = AppData+    { appSource = forever $ lift (TLS.recvData ctx) >>= yield+    , appSink = CL.mapM_ $ TLS.sendData ctx . L.fromChunks . return+    , appSockAddr = addr+    , appLocalAddr = mlocal+    }  -- taken from stunnel example in tls-extra ciphers :: [TLS.Cipher]
network-conduit-tls.cabal view
@@ -1,5 +1,5 @@ name:                network-conduit-tls-version:             1.0.0.3+version:             1.0.1 synopsis:            Create TLS-aware network code with conduits description:         Uses the tls package for a pure-Haskell implementation. homepage:            https://github.com/snoyberg/conduit