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

Network.LibP2P.NAT.DCUtR.Message

Description

DCUtR (Direct Connection Upgrade through Relay) message encoding/decoding.

Protocol: libp2pdcutr Wire format: varint-length-prefixed protobuf, max 4 KiB

HolePunch message: field 1: type (required) - CONNECT(100) or SYNC(300) field 2: ObsAddrs (repeated bytes) - observed multiaddr binary

Synopsis

Types

data HolePunchType Source #

HolePunch message type.

Constructors

HPConnect 
HPSync 

data HolePunchMessage Source #

HolePunch message.

Constructors

HolePunchMessage 

Fields

Type conversion

holePunchTypeToWord :: HolePunchType -> Word32 Source #

Convert HolePunchType to wire value.

wordToHolePunchType :: Word32 -> Maybe HolePunchType Source #

Convert wire value to HolePunchType.

Protobuf encode/decode (no framing)

encodeHolePunchMessage :: HolePunchMessage -> ByteString Source #

Encode HolePunchMessage to protobuf (no framing).

decodeHolePunchMessage :: ByteString -> Either ParseError HolePunchMessage Source #

Decode HolePunchMessage from protobuf.

Wire framing (uvarint length prefix)

encodeHolePunchFramed :: HolePunchMessage -> ByteString Source #

Encode with uvarint length prefix.

decodeHolePunchFramed :: Int -> ByteString -> Either String HolePunchMessage Source #

Decode from uvarint-length-prefixed bytes.

Stream I/O helpers

writeHolePunchMessage :: StreamIO -> HolePunchMessage -> IO () Source #

Write a framed HolePunch message to a stream.

readHolePunchMessage :: StreamIO -> Int -> IO (Either String HolePunchMessage) Source #

Read a framed HolePunch message from a stream.

Constants

maxDCUtRMessageSize :: Int Source #

Maximum DCUtR message size: 4 KiB (per spec).

dcutrProtocolId :: Text Source #

DCUtR protocol identifier.