@hackage network-transport-quic0.1.2
Networking layer for Cloud Haskell based on QUIC
Categories
License
BSD-3-Clause
Maintainer
The Distributed Haskell team
Links
Versions
Installation
Tested Compilers
Dependencies (12)
- async >=2.2 && <2.3
- base >=4.14 && <5
- binary >=0.8 && <0.10
- bytestring >=0.11 && <0.13
- containers >=0.6 && <0.9
- microlens-platform ^>=0.4 Show all…
Dependents (0)
network-transport-quic
This package provides an implementation of the network-transport interface, where networking is done via the QUIC protocol. The primary use-case for this package is as a Cloud Haskell backend.
QUIC has many advantages over TCP, including:
- No head-of-line blocking. Independent streams mean packet loss on one stream doesn't stall others;
- Connection migration. Connections survive IP address changes, which is important when a device switches from e.g. WIFI to 5G;
- Built-in encryption via TLS 1.3;
In benchmarks, network-transport-quic performs better than network-transport-tcp in dense network topologies. For example, if every EndPoint in your network connects to every other EndPoint, you might benefit greatly from switching to network-transport-quic!
Usage example
Provided you have a TLS 1.3 certificate, you can create a Transport like so:
import Data.List.NonEmpty qualified as NonEmpty
import Network.Transport.QUIC (QUICTransportConfig(..), createTransport, credentialLoadX509)
main = do
let certificate = "path/to/cert.crt"
key = "path/to/cert.key"
creds <- credentialLoadX509 certificate key
case creds of
Left error_message -> error error_message
Right credential -> do
let config = QUICTransportConfig
{ hostName = "my.hostname.com" -- or some IP address
, serviceName = "https" -- alternatively, some port number
, credentials = NonEmpty.singleton credential
, validateCredentials = True -- should be 'False' for self-signed certificate
}
transport <- createTransport config
...
There are tools online to help create self-signed TLS 1.3 certificates.