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


-- | Abstraction over creating network connections with SOCKS5 and TLS
--   
--   This package provides an abstraction for communicating with
--   line-oriented network services while abstracting over the use of
--   SOCKS5 and TLS (via OpenSSL)
@package hookup
@version 0.1.0.0


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

-- | Parameters for <a>connect</a>.
data ConnectionParams
ConnectionParams :: HostName -> PortNumber -> Maybe SocksParams -> Maybe TlsParams -> ConnectionParams

-- | Destination host
[cpHost] :: ConnectionParams -> HostName

-- | Destination TCP port
[cpPort] :: ConnectionParams -> PortNumber

-- | Optional SOCKS5 parameters
[cpSocks] :: ConnectionParams -> Maybe SocksParams

-- | Optional TLS parameters
[cpTls] :: ConnectionParams -> Maybe TlsParams

-- | SOCKS5 connection parameters
data SocksParams
SocksParams :: HostName -> PortNumber -> SocksParams

-- | SOCKS server host
[spHost] :: SocksParams -> HostName

-- | SOCKS server port
[spPort] :: SocksParams -> PortNumber

-- | TLS connection parameters
data TlsParams
TlsParams :: Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> String -> Bool -> TlsParams
[tpClientCertificate] :: TlsParams -> Maybe FilePath
[tpClientPrivateKey] :: TlsParams -> Maybe FilePath
[tpServerCertificate] :: TlsParams -> Maybe FilePath
[tpCipherSuite] :: TlsParams -> String
[tpInsecure] :: TlsParams -> Bool

-- | 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.
data Connection

-- | Open network connection to TCP service specified by the given
--   parameters.
--   
--   Throws <a>IOError</a>, <a>SocksError</a>, <a>ProtocolError</a>,
--   <a>ConnectionFailure</a>
connect :: ConnectionParams -> IO Connection

-- | Receive a line from the network connection. Both <tt>"rn"</tt> and
--   <tt>"n"</tt> are recognized.
--   
--   Throws: <tt>ConnectionAbruptlyTerminated</tt>,
--   <a>ConnectionFailure</a>, <a>IOError</a>
recvLine :: Connection -> Int -> IO (Maybe ByteString)

-- | Send bytes on the network connection. Ensures that the whole message
--   is sent.
--   
--   Throws: <a>IOError</a>, <tt>ProtocolError</tt>
send :: Connection -> ByteString -> IO ()

-- | Close network connection.
close :: Connection -> IO ()

-- | Type for errors that can be thrown by this package.
data ConnectionFailure

-- | Failure during <tt>getAddrInfo</tt> resolving remote host
HostnameResolutionFailure :: IOError -> ConnectionFailure

-- | Failure during <a>connect</a> to remote host
ConnectionFailure :: [IOError] -> ConnectionFailure

-- | Failure during <a>recvLine</a>
LineTooLong :: ConnectionFailure

-- | Incomplete line during <a>recvLine</a>
LineTruncated :: ConnectionFailure
instance GHC.Show.Show Hookup.ConnectionFailure
instance GHC.Exception.Exception Hookup.ConnectionFailure
