| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data HolePunchType
- data HolePunchMessage = HolePunchMessage {
- hpType :: !HolePunchType
- hpObsAddrs :: ![ByteString]
- holePunchTypeToWord :: HolePunchType -> Word32
- wordToHolePunchType :: Word32 -> Maybe HolePunchType
- encodeHolePunchMessage :: HolePunchMessage -> ByteString
- decodeHolePunchMessage :: ByteString -> Either ParseError HolePunchMessage
- encodeHolePunchFramed :: HolePunchMessage -> ByteString
- decodeHolePunchFramed :: Int -> ByteString -> Either String HolePunchMessage
- writeHolePunchMessage :: StreamIO -> HolePunchMessage -> IO ()
- readHolePunchMessage :: StreamIO -> Int -> IO (Either String HolePunchMessage)
- maxDCUtRMessageSize :: Int
- dcutrProtocolId :: Text
Types
data HolePunchType Source #
HolePunch message type.
Instances
| Show HolePunchType Source # | |
Defined in Network.LibP2P.NAT.DCUtR.Message Methods showsPrec :: Int -> HolePunchType -> ShowS # show :: HolePunchType -> String # showList :: [HolePunchType] -> ShowS # | |
| Eq HolePunchType Source # | |
Defined in Network.LibP2P.NAT.DCUtR.Message Methods (==) :: HolePunchType -> HolePunchType -> Bool # (/=) :: HolePunchType -> HolePunchType -> Bool # | |
data HolePunchMessage Source #
HolePunch message.
Constructors
| HolePunchMessage | |
Fields
| |
Instances
| Show HolePunchMessage Source # | |
Defined in Network.LibP2P.NAT.DCUtR.Message Methods showsPrec :: Int -> HolePunchMessage -> ShowS # show :: HolePunchMessage -> String # showList :: [HolePunchMessage] -> ShowS # | |
| Eq HolePunchMessage Source # | |
Defined in Network.LibP2P.NAT.DCUtR.Message Methods (==) :: HolePunchMessage -> HolePunchMessage -> Bool # (/=) :: HolePunchMessage -> HolePunchMessage -> Bool # | |
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.