This opaque type represent a connection to a destination.
Modulecrypton-connection-0.4.5Haskell2010
Network.Connection
Simple connection abstraction
- 9 types
- 16 values
- Packagecrypton-connection-0.4.5
- Exports25
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceConnection.hs
Type for a connection
6 declarationsreturn a simple tuple of the port and hostname that we're connected to.
Connection Parameters to establish a Connection.
The strict minimum is an hostname and the port.
If you need to establish a TLS connection, you should make sure connectionUseSecure is correctly set.
If you need to connect through a SOCKS, you should make sure connectionUseSocks is correctly set.
Constructors
ConnectionParamsconnectionHostname :: HostNamehost name to connect to.
connectionPort :: PortNumberport number to connect to.
connectionUseSecure :: Maybe TLSSettingsoptional TLS parameters.
connectionUseSocks :: Maybe ProxySettingsoptional Proxy/Socks configuration.
TLS Settings that can be either expressed as simple settings, or as full blown TLS.Params settings.
Unless you need access to parameters that are not accessible through the simple settings, you should use TLSSettingsSimple.
Constructors
TLSSettingsSimplesettingDisableCertificateValidation :: BoolDisable certificate verification completely, this make TLS/SSL vulnerable to a MITM attack. not recommended to use, but for testing.
settingDisableSession :: BoolDisable session management. TLS/SSL connections will always re-established their context. Not Implemented Yet.
settingUseServerName :: BoolUse server name extension. Not Implemented Yet.
settingClientSupported :: SupportedUsed for the clientSupported member of ClientParams.
TLSSettings ClientParamsfull blown TLS Settings directly using TLS.Params. for power users.
Instances2Show, Default
Show TLSSettingsDefined in crypton-connection-0.4.5 · Network.Connection.TypesDefault TLSSettingsDefined in crypton-connection-0.4.5 · Network.Connection.Types
Proxy settings for the connection.
OtherProxy handles specific application-level proxies like HTTP proxies.
The simple SOCKS settings is just the hostname and portnumber of the SOCKS proxy server.
That's for now the only settings in the SOCKS package, socks password, or any sort of other authentications is not yet implemented.
Constructors
SockSettingsSimple HostName PortNumberSockSettingsEnvironment (Maybe String)OtherProxy HostName PortNumber
Exceptions
3 declarationsThis is the exception raised if we reached the user specified limit for the line in ConnectionGetLine.
Instances2Show, Exception
Show LineTooLongDefined in crypton-connection-0.4.5 · Network.ConnectionException LineTooLongDefined in crypton-connection-0.4.5 · Network.Connection
Exception raised when there's no resolution for a specific host
Constructors
Instances2Show, Exception
Show HostNotResolvedDefined in crypton-connection-0.4.5 · Network.ConnectionException HostNotResolvedDefined in crypton-connection-0.4.5 · Network.Connection
Exception raised when the connect failed
Constructors
Instances2Show, Exception
Show HostCannotConnectDefined in crypton-connection-0.4.5 · Network.ConnectionException HostCannotConnectDefined in crypton-connection-0.4.5 · Network.Connection
Library initialization
2 declarationsInitialize the library with shared parameters between connection.
Shared values (certificate store, sessions, ..) between connections
At the moment, this is only strictly needed to shared sessions and certificates when using a TLS enabled connection.
Connection operation
4 declarationsUse an already established handle to create a connection object.
if the TLS Settings is set, it will do the handshake with the server. The SOCKS settings have no impact here, as the handle is already established
Use an already established handle to create a connection object.
if the TLS Settings is set, it will do the handshake with the server. The SOCKS settings have no impact here, as the handle is already established
connectTo :: ConnectionContextThe global context of this connection.
-> ConnectionParamsThe parameters for this connection (where to connect, and such).
-> IO ConnectionThe new established connection on success.
Connect to a destination using the parameter
Close a connection.
Sending and receiving data
7 declarationsGet some bytes from a connection.
The size argument is just the maximum that could be returned to the user. The call will return as soon as there's data, even if there's less than requested. Hence, it behaves like hGetSome.
On end of input, connectionGet returns 0, but subsequent calls will throw
an E.isEOFError exception.
Get exact count of bytes from a connection.
The size argument is the exact amount that must be returned to the user. The call will wait until all data is available. Hence, it behaves like hGet.
On end of input, connectionGetExact will throw an E.isEOFError
exception.
Get the next block of data from the connection.
Like connectionGetChunk, but return the unused portion to the buffer, where it will be the next chunk read.
connectionGetLine :: IntMaximum number of bytes before raising a LineTooLong exception
-> ConnectionConnection
-> IO ByteStringThe received line with the LF trimmed
Get the next line, using ASCII LF as the line terminator.
This throws an isEOFError exception on end of input, and LineTooLong when
the number of bytes gathered is over the limit without a line terminator.
The actual line returned can be bigger than the limit specified, provided that the last chunk returned by the underlaying backend contains a LF. Put another way: Only when we need more input and limit is reached that the LineTooLong exception will be raised.
An end of file will be considered as a line terminator too, if the line is not empty.
Wait for input to become available on a connection.
As with hWaitForInput, the timeout value is given in milliseconds. If the timeout value is less than zero, then connectionWaitForInput waits indefinitely.
Unlike hWaitForInput, this function does not do any decoding, so it returns true when there is any available input, not just full characters.
Put a block of data in the connection.
TLS related operations
3 declarationsActivate secure layer using the parameters specified.
This is typically used to negotiate a TLS channel on an already established channel, e.g., supporting a STARTTLS command. It also flushes the received buffer to prevent application confusing received data before and after the setSecure call.
If the connection is already using TLS, nothing else happens.
Returns if the connection is establish securely or not.