libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

Network.LibP2P.NAT.DCUtR.DCUtR

Description

DCUtR (Direct Connection Upgrade through Relay) protocol.

Protocol: libp2pdcutr Coordinates hole punching over a relayed connection using a 3-message exchange with RTT-based timing synchronization.

Message flow: B (initiator) sends CONNECT with B's observed addresses A (handler) sends CONNECT with A's observed addresses B sends SYNC B waits RTT/2, then dials A's addresses A receives SYNC, then dials B's addresses immediately Both peers attempt direct connections at approximately the same time

Synopsis

Types

data DCUtRConfig Source #

DCUtR configuration.

Constructors

DCUtRConfig 

Fields

data DCUtRResult Source #

DCUtR result.

Instances

Instances details
Show DCUtRResult Source # 
Instance details

Defined in Network.LibP2P.NAT.DCUtR.DCUtR

Eq DCUtRResult Source # 
Instance details

Defined in Network.LibP2P.NAT.DCUtR.DCUtR

Protocol operations

initiateDCUtR :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IO DCUtRResult Source #

Peer B (initiator): run the DCUtR exchange over a relayed stream.

Flow: 1. Send CONNECT with own observed addresses 2. Read A's CONNECT (measure RTT) 3. Send SYNC 4. Wait RTT/2, then dial A's addresses

handleDCUtR :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IO DCUtRResult Source #

Peer A (handler): handle the DCUtR exchange over a relayed stream.

Flow: 1. Read B's CONNECT 2. Send CONNECT with own observed addresses 3. Read SYNC 4. Dial B's addresses immediately

Variants for testing

initiateDCUtRWithRTT :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IORef (Maybe NominalDiffTime) -> IO DCUtRResult Source #

Initiator variant that captures RTT for testing.

initiateDCUtRCapture :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IORef [ByteString] -> IO DCUtRResult Source #

Initiator variant that captures received addresses for testing.

handleDCUtRCapture :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IORef [ByteString] -> IO DCUtRResult Source #

Handler variant that captures received addresses for testing.