-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Create TLS-aware network code with conduits
--   
--   Uses the tls package for a pure-Haskell implementation.
@package network-conduit-tls
@version 1.4.0.1

module Data.Conduit.Network.TLS.Internal
data TLSConfig
TLSConfig :: HostPreference -> Int -> TlsCertData -> Bool -> TLSConfig
[tlsHost] :: TLSConfig -> HostPreference
[tlsPort] :: TLSConfig -> Int
[tlsCertData] :: TLSConfig -> TlsCertData
[tlsNeedLocalAddr] :: TLSConfig -> Bool
data TlsCertData
TlsCertData :: IO ByteString -> IO [ByteString] -> IO ByteString -> TlsCertData
[getTLSCert] :: TlsCertData -> IO ByteString
[getTLSChainCerts] :: TlsCertData -> IO [ByteString]
[getTLSKey] :: TlsCertData -> IO ByteString

module Data.Conduit.Network.TLS
type ApplicationStartTLS = GeneralApplicationStartTLS IO ()

type GeneralApplicationStartTLS (m :: Type -> Type) a = (AppData, AppData -> m () -> m ()) -> m a
data TLSConfig

-- | allow to build a server config directly from raw bytestring data
--   (exact same string as if the certificates were read from the
--   filesystem). this enables to plug another backend to fetch certifcates
--   (other than FS)
tlsConfigBS :: HostPreference -> Int -> ByteString -> ByteString -> TLSConfig
tlsConfig :: HostPreference -> Int -> FilePath -> FilePath -> TLSConfig

-- | Like <a>tlsConfigBS</a>, but also allow specifying chain certificates.
--   
--   Since 1.1.1
tlsConfigChainBS :: HostPreference -> Int -> ByteString -> [ByteString] -> ByteString -> TLSConfig

-- | Like <a>tlsConfig</a>, but also allow specifying chain certificates.
--   
--   Since 1.1.1
tlsConfigChain :: HostPreference -> Int -> FilePath -> [FilePath] -> FilePath -> TLSConfig
tlsHost :: TLSConfig -> HostPreference
tlsPort :: TLSConfig -> Int
tlsNeedLocalAddr :: TLSConfig -> Bool

-- | Create an <tt>AppData</tt> from an existing tls <tt>Context</tt>
--   value. This is a lower level function, allowing you to create a
--   connection in any way you want.
--   
--   Sample usage:
--   
--   <pre>
--   import Network.Simple.TCP.TLS
--   
--   myapp :: Application IO
--   ...
--   main = do
--       cset &lt;- getDefaultClientSettings
--       connect cset "host" "port" $
--           (\(ctx, addr) -&gt; myapp $ tlsAppData ctx addr Nothing)
--   </pre>
--   
--   Since 1.0.1
tlsAppData :: Context -> SockAddr -> Maybe SockAddr -> AppData
runTCPServerTLS :: TLSConfig -> (AppData -> IO ()) -> IO ()

-- | Like <a>runTCPServerTLS</a>, but monad can be any instance of
--   <a>MonadUnliftIO</a>.
--   
--   Note that any changes to the monadic state performed by individual
--   client handlers will be discarded. If you have mutable state you want
--   to share among multiple handlers, you need to use some kind of mutable
--   variables.
--   
--   Since 1.1.2
runGeneralTCPServerTLS :: MonadUnliftIO m => TLSConfig -> (AppData -> m ()) -> m ()

-- | run a server un-crypted but also pass a call-back to trigger a
--   StartTLS handshake on the underlying connection
--   
--   Sample usage:
--   
--   <pre>
--   runTCPServerStartTLS serverConfig $ \(appData,startTLS) -&gt; do
--     abortTLS &lt;- doSomethingInClear appData
--     unless abortTLS $ startTls $ \appDataTls -&gt; do
--       doSomethingSSL appDataTls
--   </pre>
runTCPServerStartTLS :: MonadUnliftIO m => TLSConfig -> GeneralApplicationStartTLS m () -> m ()

-- | Settings type for TLS client connection.
--   
--   Since 1.0.2
data TLSClientConfig

-- | Smart constructor for <tt>TLSClientConfig</tt>.
--   
--   Since 1.0.2
tlsClientConfig :: Int -> ByteString -> TLSClientConfig

-- | Run an application with the given configuration.
--   
--   Since 1.0.2
runTLSClient :: MonadUnliftIO m => TLSClientConfig -> (AppData -> m a) -> m a

-- | Run an application with the given configuration. starting with a clear
--   connection but provide also a call back to trigger a StartTLS
--   handshake on the connection
--   
--   Since 1.0.2
runTLSClientStartTLS :: MonadUnliftIO m => TLSClientConfig -> GeneralApplicationStartTLS m a -> m a

-- | Since 1.0.2
tlsClientPort :: TLSClientConfig -> Int

-- | Since 1.0.2
tlsClientHost :: TLSClientConfig -> ByteString

-- | Default is True. If set to <tt>False</tt>, will make a non-TLS
--   connection.
--   
--   Since 1.0.2
tlsClientUseTLS :: TLSClientConfig -> Bool

-- | TLS settings to use. If not provided, defaults will be provided.
--   
--   Since 1.0.2
tlsClientTLSSettings :: TLSClientConfig -> TLSSettings

-- | Socks configuration; default is <tt>Nothing</tt>. If absent, Socks
--   will not be used.
--   
--   Since 1.0.2
tlsClientSockSettings :: TLSClientConfig -> Maybe SockSettings

-- | Connection context. Default is <tt>Nothing</tt>, which will generate a
--   new context automatically. If you will be making many connections,
--   it's recommended to call <a>initConnectionContext</a> yourself.
--   
--   Since 1.0.2
tlsClientConnectionContext :: TLSClientConfig -> Maybe ConnectionContext

-- | Read from a <a>Connection</a>.
sourceConnection :: forall (m :: Type -> Type) i. MonadIO m => Connection -> ConduitT i ByteString m ()

-- | Write to a <a>Connection</a>.
sinkConnection :: forall (m :: Type -> Type) o. MonadIO m => Connection -> ConduitT ByteString o m ()
