| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data DCUtRConfig = DCUtRConfig {}
- data DCUtRResult
- initiateDCUtR :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IO DCUtRResult
- handleDCUtR :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IO DCUtRResult
- initiateDCUtRWithRTT :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IORef (Maybe NominalDiffTime) -> IO DCUtRResult
- initiateDCUtRCapture :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IORef [ByteString] -> IO DCUtRResult
- handleDCUtRCapture :: DCUtRConfig -> StreamIO -> [Multiaddr] -> IORef [ByteString] -> IO DCUtRResult
Types
data DCUtRResult Source #
DCUtR result.
Constructors
| DCUtRSuccess | |
| DCUtRFailed String |
Instances
| Show DCUtRResult Source # | |
Defined in Network.LibP2P.NAT.DCUtR.DCUtR Methods showsPrec :: Int -> DCUtRResult -> ShowS # show :: DCUtRResult -> String # showList :: [DCUtRResult] -> ShowS # | |
| Eq DCUtRResult Source # | |
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.