hwormhole-0.1.0.0: magic-wormhole client

Safe HaskellNone
LanguageHaskell2010

Transit.Internal.Network

Contents

Description

 
Synopsis

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

Constructors

RelayEndpoint 

Fields

Instances
Eq RelayEndpoint Source # 
Instance details

Defined in Transit.Internal.Network

Show RelayEndpoint Source # 
Instance details

Defined in Transit.Internal.Network

Methods

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

Constructors

TCPEndpoint 

Fields

Instances
Eq TCPEndpoint Source # 
Instance details

Defined in Transit.Internal.Network

Methods

(==) :: TCPEndpoint -> TCPEndpoint -> Bool

(/=) :: TCPEndpoint -> TCPEndpoint -> Bool

Show TCPEndpoint Source # 
Instance details

Defined in Transit.Internal.Network

Methods

showsPrec :: Int -> TCPEndpoint -> ShowS

show :: TCPEndpoint -> String

showList :: [TCPEndpoint] -> ShowS

data TransitEndpoint Source #

A type representing an "authenticated" TCP endpoint

Constructors

TransitEndpoint 

Fields

Instances
Eq TransitEndpoint Source # 
Instance details

Defined in Transit.Internal.Network

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

Constructors

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 # 
Instance details

Defined in Transit.Internal.Network

Show CommunicationError Source # 
Instance details

Defined in Transit.Internal.Network

Methods

showsPrec :: Int -> CommunicationError -> ShowS

show :: CommunicationError -> String

showList :: [CommunicationError] -> ShowS