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

Copyright(c) Eric Mertens 2016
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Hookup

Contents

Description

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

Synopsis

Configuration

data ConnectionParams Source #

Parameters for connect.

Constructors

ConnectionParams 

Fields

data SocksParams Source #

SOCKS5 connection parameters

Constructors

SocksParams 

Fields

data TlsParams Source #

TLS connection parameters. These parameters are passed to OpenSSL when making a secure connection.

Constructors

TlsParams 

Fields

defaultFamily :: Family Source #

Default Family value is unspecified and allows both INET and INET6.

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 "\r\n" and "\n" are recognized.

Returning Nothing means that the peer has closed its half of the connection.

Unterminated lines will raise a LineTruncated exception. This can happen if the peer transmits some data and closes its end without transmitting a line terminator.

Throws: ConnectionAbruptlyTerminated, ConnectionFailure, IOError

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

Send bytes on the network connection.

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