hookup-0.1.0.0: Abstraction over creating network connections with SOCKS5 and TLS

Copyright | (c) Eric Mertens 2016
License | ISC
Maintainer | emertens@gmail.com
Safe Haskell | None
Language | Haskell2010

Hookup

Contents

- Configuration
- Connections
- Errors

Description

This module provides a uniform interface to network connections with optional support for TLS and SOCKS.

Synopsis

- data ConnectionParams = ConnectionParams {
  - cpHost :: HostName
  - cpPort :: PortNumber
  - cpSocks :: Maybe SocksParams
  - cpTls :: Maybe TlsParams
  }
- data SocksParams = SocksParams {
  - spHost :: HostName
  - spPort :: PortNumber
  }
- data TlsParams = TlsParams {
  - tpClientCertificate :: Maybe FilePath
  - tpClientPrivateKey :: Maybe FilePath
  - tpServerCertificate :: Maybe FilePath
  - tpCipherSuite :: String
  - tpInsecure :: Bool
  }
- data Connection
- connect :: ConnectionParams -> IO Connection
- recvLine :: Connection -> Int -> IO (Maybe ByteString)
- send :: Connection -> ByteString -> IO ()
- close :: Connection -> IO ()
- data ConnectionFailure
  - = HostnameResolutionFailure IOError
  - | ConnectionFailure [IOError]
  - | LineTooLong
  - | LineTruncated

# Configuration

data ConnectionParams Source #

Parameters for `connect`.

Constructors

ConnectionParams |

Fields

- cpHost :: HostName

  Destination host

- cpPort :: PortNumber

  Destination TCP port

- cpSocks :: Maybe SocksParams

  Optional SOCKS5 parameters

- cpTls :: Maybe TlsParams

  Optional TLS parameters

data SocksParams Source #

SOCKS5 connection parameters

Constructors

SocksParams |

Fields

- spHost :: HostName

  SOCKS server host

- spPort :: PortNumber

  SOCKS server port

data TlsParams Source #

TLS connection parameters

Constructors

TlsParams |

Fields

- tpClientCertificate :: Maybe FilePath
- tpClientPrivateKey :: Maybe FilePath
- tpServerCertificate :: Maybe FilePath
- tpCipherSuite :: String
- tpInsecure :: Bool

# Connections

data Connection Source #

A connection to a network service along with its read buffer used for line-oriented protocols. The connection could be a plain network connection, SOCKS connected, or TLS.

connect :: ConnectionParams -> IO Connection Source #

Open network connection to TCP service specified by the given parameters.

Throws `IOError`, `SocksError`, `ProtocolError`, `ConnectionFailure`

recvLine :: Connection -> Int -> IO (Maybe ByteString) Source #

Receive a line from the network connection. Both `"rn"` and `"n"` are recognized.

Throws: `ConnectionAbruptlyTerminated`, `ConnectionFailure`, `IOError`

send :: Connection -> ByteString -> IO () Source #

Send bytes on the network connection. Ensures that the whole message is sent.

Throws: `IOError`, `ProtocolError`

close :: Connection -> IO () Source #

Close network connection.

# Errors

data ConnectionFailure Source #

Type for errors that can be thrown by this package.

Constructors

HostnameResolutionFailure IOError | Failure during `getAddrInfo` resolving remote host
ConnectionFailure [IOError] | Failure during `connect` to remote host
LineTooLong | Failure during `recvLine`
LineTruncated | Incomplete line during `recvLine`

Instances

Show ConnectionFailure Source # |
Methods showsPrec :: Int -> ConnectionFailure -> ShowS # show :: ConnectionFailure -> String # showList :: [ConnectionFailure] -> ShowS #
Exception ConnectionFailure Source # |
Methods toException :: ConnectionFailure -> SomeException # fromException :: SomeException -> Maybe ConnectionFailure # displayException :: ConnectionFailure -> String #