Safe Haskell | None |
---|
This module exports facilities allowing you to safely obtain, use and
release TLS-secured TCP connections within a Pipes pipeline, by relying on
pipes-safe
.
This module is meant to be used together with Pipes.Network.TCP.TLS, and it
overrides some functions from Network.Simple.TCP so that they support
MonadSafe
. Additionally, it also exports pipes that establish a
TLS-secured TCP connection and interact with it unidirectionally, in a
streaming fashion at once.
You are encouraged to use this module together with Pipes.Network.TCP.TLS and Network.Simple.TCP.TLS as follows:
import qualified Network.Simple.TCP.TLS as TLS hiding (connect, serve, listen, accept) import qualified Pipes.Network.TCP.TLS as TLS import qualified Pipes.Network.TCP.TLS.Safe as TLS
- connect :: (MonadSafe m, Base m ~ IO) => ClientSettings -> HostName -> ServiceName -> ((Context, SockAddr) -> m r) -> m r
- serve :: (MonadSafe m, Base m ~ IO) => ServerSettings -> HostPreference -> ServiceName -> ((Context, SockAddr) -> IO ()) -> m r
- listen :: (MonadSafe m, ~ (* -> *) (Base m) IO) => HostPreference -> ServiceName -> ((Socket, SockAddr) -> m r) -> m r
- accept :: (MonadSafe m, Base m ~ IO) => ServerSettings -> Socket -> ((Context, SockAddr) -> m r) -> m r
- fromConnect :: (MonadSafe m, Base m ~ IO) => ClientSettings -> HostName -> ServiceName -> Producer' ByteString m ()
- toConnect :: (MonadSafe m, Base m ~ IO) => ClientSettings -> HostName -> ServiceName -> Consumer' ByteString m ()
- fromServe :: (MonadSafe m, Base m ~ IO) => ServerSettings -> HostPreference -> ServiceName -> Producer' ByteString m ()
- toServe :: (MonadSafe m, Base m ~ IO) => ServerSettings -> HostPreference -> ServiceName -> Consumer' ByteString m r
MonadSafe
-compatible upgrades
The following functions are analogous versions of those exported by
Network.Simple.TCP.TLS, but compatible with MonadSafe
.
connect :: (MonadSafe m, Base m ~ IO) => ClientSettings -> HostName -> ServiceName -> ((Context, SockAddr) -> m r) -> m rSource
Like connect
from Network.Simple.TCP.TLS, but
compatible with MonadSafe
.
serve :: (MonadSafe m, Base m ~ IO) => ServerSettings -> HostPreference -> ServiceName -> ((Context, SockAddr) -> IO ()) -> m rSource
Like serve
from Network.Simple.TCP.TLS, but
compatible with MonadSafe
.
listen :: (MonadSafe m, ~ (* -> *) (Base m) IO) => HostPreference -> ServiceName -> ((Socket, SockAddr) -> m r) -> m r
Like listen
from Network.Simple.TCP, but compatible
with MonadSafe
.
accept :: (MonadSafe m, Base m ~ IO) => ServerSettings -> Socket -> ((Context, SockAddr) -> m r) -> m rSource
Like accept
from Network.Simple.TCP.TLS, but
compatible with MonadSafe
.
Streaming
Client side
The following proxies allow you to easily connect to a TLS-secured TCP server and immediately interact with it in a streaming fashion, all at once, instead of having to perform the individual steps separately.
:: (MonadSafe m, Base m ~ IO) | |
=> ClientSettings | TLS settings. |
-> HostName | |
-> ServiceName | Server service port. |
-> Producer' ByteString m () |
Connect to a TLS-secured TCP server and send downstream the decrypted bytes received from the remote end.
Up to 16384
decrypted bytes will be received at once. The TLS connection is
automatically renegotiated if a ClientHello message is received.
If the remote peer closes its side of the connection of EOF is reached, this proxy returns.
The connection is closed when done or in case of exceptions.
:: (MonadSafe m, Base m ~ IO) | |
=> ClientSettings | TLS settings. |
-> HostName | Server host name. |
-> ServiceName | Server service port. |
-> Consumer' ByteString m () |
Connects to a TLS-secured TCP server, then repeatedly encrypts and sends to the remote end the bytes received from upstream.
The connection is properly closed when done or in case of exceptions.
Server side
The following proxies allow you to easily run a TLS-secured TCP server and immediately interact with incoming connections in a streaming fashion, all at once, instead of having to perform the individual steps separately.
:: (MonadSafe m, Base m ~ IO) | |
=> ServerSettings | TLS settings. |
-> HostPreference | Preferred host to bind. |
-> ServiceName | Service port to bind. |
-> Producer' ByteString m () |
Binds a listening TCP socket, accepts a single TLS-secured connection and sends downstream any decrypted bytes received from the remote end.
Up to 16384
decrypted bytes will be received at once. The TLS connection is
automatically renegotiated if a ClientHello message is received.
If the remote peer closes its side of the connection of EOF is reached, this proxy returns.
Both the listening and connection sockets are closed when done or in case of exceptions.
:: (MonadSafe m, Base m ~ IO) | |
=> ServerSettings | TLS settings. |
-> HostPreference | Preferred host to bind. |
-> ServiceName | Service port to bind. |
-> Consumer' ByteString m r |
Binds a listening TCP socket, accepts a single TLS-secured connection, and repeatedly sends to the remote end any bytes received from upstream.
If the remote peer closes its side of the connection, this proxy returns.
Both the listening and connection sockets are closed when done or in case of exceptions.