Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- buildHints :: PortNumber -> RelayEndpoint -> IO (Set ConnectionHint)
- buildRelayHints :: RelayEndpoint -> Set ConnectionHint
- parseTransitRelayUri :: String -> Maybe RelayEndpoint
- data RelayEndpoint = RelayEndpoint {}
- sendBuffer :: TCPEndpoint -> ByteString -> IO Int
- recvBuffer :: TCPEndpoint -> Int -> IO ByteString
- closeConnection :: TransitEndpoint -> IO ()
- data TCPEndpoint = TCPEndpoint {}
- data TransitEndpoint = TransitEndpoint {
- peerEndpoint :: TCPEndpoint
- senderKey :: Key
- receiverKey :: Key
- tcpListener :: IO Socket
- startServer :: Socket -> IO (Either CommunicationError TCPEndpoint)
- startClient :: [ConnectionHint] -> IO (Either CommunicationError TCPEndpoint)
- data CommunicationError
- = ConnectionError Text
- | OfferError Text
- | TransitError Text
- | Sha256SumError Text
- | UnknownPeerMessage Text
build hints (direct and relay) from relay url, port number and the network interfaces.
buildHints :: PortNumber -> RelayEndpoint -> IO (Set ConnectionHint) Source #
Build a client's connection hint
buildRelayHints :: RelayEndpoint -> Set ConnectionHint Source #
The client at the sending side and receiving side may be invoked with different relay hint urls. These get exchanged in the transit message. After successfully receiving the transit message, each client should combine the hints of the peer along with its relay hints to get the full set of hints.
parse and build transit relay hints
parseTransitRelayUri :: String -> Maybe RelayEndpoint Source #
Parse transit url of the form tcp:hostname:port
data RelayEndpoint Source #
Type representing a Relay Endpoint URL
Instances
Eq RelayEndpoint Source # | |
Defined in Transit.Internal.Network (==) :: RelayEndpoint -> RelayEndpoint -> Bool (/=) :: RelayEndpoint -> RelayEndpoint -> Bool | |
Show RelayEndpoint Source # | |
Defined in Transit.Internal.Network showsPrec :: Int -> RelayEndpoint -> ShowS show :: RelayEndpoint -> String showList :: [RelayEndpoint] -> ShowS |
low level bytestring buffer send/receive over a socket
sendBuffer :: TCPEndpoint -> ByteString -> IO Int Source #
Low level function to send a fixed length bytestring to the peer represented by ep.
recvBuffer :: TCPEndpoint -> Int -> IO ByteString Source #
Low level function to receive a byte buffer of specified length from the peer represented by ep.
TCP Endpoint
closeConnection :: TransitEndpoint -> IO () Source #
Close the peer network connection.
data TCPEndpoint Source #
A type representing the connected TCP endpoint
Instances
Eq TCPEndpoint Source # | |
Defined in Transit.Internal.Network (==) :: TCPEndpoint -> TCPEndpoint -> Bool (/=) :: TCPEndpoint -> TCPEndpoint -> Bool | |
Show TCPEndpoint Source # | |
Defined in Transit.Internal.Network showsPrec :: Int -> TCPEndpoint -> ShowS show :: TCPEndpoint -> String showList :: [TCPEndpoint] -> ShowS |
data TransitEndpoint Source #
A type representing an "authenticated" TCP endpoint
TransitEndpoint | |
|
Instances
Eq TransitEndpoint Source # | |
Defined in Transit.Internal.Network (==) :: TransitEndpoint -> TransitEndpoint -> Bool (/=) :: TransitEndpoint -> TransitEndpoint -> Bool |
TCP Listener that listens on a random port, Server and Client
tcpListener :: IO Socket Source #
Listen on all the interfaces on a randomly assigned default port
startServer :: Socket -> IO (Either CommunicationError TCPEndpoint) Source #
Accept and return the TCP Endpoint representing the peer
startClient :: [ConnectionHint] -> IO (Either CommunicationError TCPEndpoint) Source #
Try to concurrently connect to the given list of connection hints and return the first peer that succeeds.
Errors
data CommunicationError Source #
Type representing the network protocol errors
ConnectionError Text | We could not establish a socket connection. |
OfferError Text | Clients could not exchange offer message. |
TransitError Text | There was an error in transit protocol exchanges. |
Sha256SumError Text | Sender got back a wrong sha256sum from the receiver. |
UnknownPeerMessage Text | We could not identify the message from peer. |
Instances
Eq CommunicationError Source # | |
Defined in Transit.Internal.Network (==) :: CommunicationError -> CommunicationError -> Bool (/=) :: CommunicationError -> CommunicationError -> Bool | |
Show CommunicationError Source # | |
Defined in Transit.Internal.Network showsPrec :: Int -> CommunicationError -> ShowS show :: CommunicationError -> String showList :: [CommunicationError] -> ShowS |