| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Network.LibP2P.NAT.Relay.Message
Description
Circuit Relay v2 message encoding/decoding (protobuf).
Two message types: HopMessage: client ↔ relay (RESERVE, CONNECT, STATUS) StopMessage: relay ↔ target (CONNECT, STATUS)
Wire format: [uvarint length][protobuf message]
HopMessage fields: type(1), peer(2), reservation(3), limit(4), status(5) StopMessage fields: type(1), peer(2), limit(3), status(4) Peer fields: id(1), addrs(2) Reservation fields: expire(1), addrs(2), voucher(3) Limit fields: duration(1), data(2)
Synopsis
- data HopMessageType
- data StopMessageType
- data RelayStatus
- data RelayPeer = RelayPeer {
- rpId :: !ByteString
- rpAddrs :: ![ByteString]
- data Reservation = Reservation {
- rsvExpire :: !(Maybe Word64)
- rsvAddrs :: ![ByteString]
- rsvVoucher :: !(Maybe ByteString)
- data RelayLimit = RelayLimit {}
- data HopMessage = HopMessage {
- hopType :: !(Maybe HopMessageType)
- hopPeer :: !(Maybe RelayPeer)
- hopReservation :: !(Maybe Reservation)
- hopLimit :: !(Maybe RelayLimit)
- hopStatus :: !(Maybe RelayStatus)
- data StopMessage = StopMessage {
- stopType :: !(Maybe StopMessageType)
- stopPeer :: !(Maybe RelayPeer)
- stopLimit :: !(Maybe RelayLimit)
- stopStatus :: !(Maybe RelayStatus)
- relayStatusToWord :: RelayStatus -> Word32
- wordToRelayStatus :: Word32 -> Maybe RelayStatus
- encodeHopMessage :: HopMessage -> ByteString
- decodeHopMessage :: ByteString -> Either ParseError HopMessage
- encodeHopFramed :: HopMessage -> ByteString
- decodeHopFramed :: Int -> ByteString -> Either String HopMessage
- writeHopMessage :: StreamIO -> HopMessage -> IO ()
- readHopMessage :: StreamIO -> Int -> IO (Either String HopMessage)
- encodeStopMessage :: StopMessage -> ByteString
- decodeStopMessage :: ByteString -> Either ParseError StopMessage
- encodeStopFramed :: StopMessage -> ByteString
- decodeStopFramed :: Int -> ByteString -> Either String StopMessage
- writeStopMessage :: StreamIO -> StopMessage -> IO ()
- readStopMessage :: StreamIO -> Int -> IO (Either String StopMessage)
- maxRelayMessageSize :: Int
- hopProtocolId :: Text
- stopProtocolId :: Text
Types
data HopMessageType Source #
HopMessage type enum.
Constructors
| HopReserve | |
| HopConnect | |
| HopStatus |
Instances
| Show HopMessageType Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> HopMessageType -> ShowS # show :: HopMessageType -> String # showList :: [HopMessageType] -> ShowS # | |
| Eq HopMessageType Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods (==) :: HopMessageType -> HopMessageType -> Bool # (/=) :: HopMessageType -> HopMessageType -> Bool # | |
data StopMessageType Source #
StopMessage type enum.
Constructors
| StopConnect | |
| StopStatus |
Instances
| Show StopMessageType Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> StopMessageType -> ShowS # show :: StopMessageType -> String # showList :: [StopMessageType] -> ShowS # | |
| Eq StopMessageType Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods (==) :: StopMessageType -> StopMessageType -> Bool # (/=) :: StopMessageType -> StopMessageType -> Bool # | |
data RelayStatus Source #
Relay status codes (shared between Hop and Stop).
Constructors
| RelayOK | 100 |
| ReservationRefused | 200 |
| ResourceLimitExceeded | 201 |
| PermissionDenied | 202 |
| ConnectionFailed | 203 |
| NoReservation | 204 |
| MalformedMessage | 400 |
| UnexpectedMessage | 401 |
Instances
| Show RelayStatus Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> RelayStatus -> ShowS # show :: RelayStatus -> String # showList :: [RelayStatus] -> ShowS # | |
| Eq RelayStatus Source # | |
Defined in Network.LibP2P.NAT.Relay.Message | |
Relay peer info (nested message).
Constructors
| RelayPeer | |
Fields
| |
data Reservation Source #
Reservation info (nested in HopMessage).
Constructors
| Reservation | |
Fields
| |
Instances
| Show Reservation Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> Reservation -> ShowS # show :: Reservation -> String # showList :: [Reservation] -> ShowS # | |
| Eq Reservation Source # | |
Defined in Network.LibP2P.NAT.Relay.Message | |
data RelayLimit Source #
Relay limit (nested in both Hop and Stop).
Constructors
| RelayLimit | |
Instances
| Show RelayLimit Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> RelayLimit -> ShowS # show :: RelayLimit -> String # showList :: [RelayLimit] -> ShowS # | |
| Eq RelayLimit Source # | |
Defined in Network.LibP2P.NAT.Relay.Message | |
data HopMessage Source #
HopMessage: client ↔ relay.
Constructors
| HopMessage | |
Fields
| |
Instances
| Show HopMessage Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> HopMessage -> ShowS # show :: HopMessage -> String # showList :: [HopMessage] -> ShowS # | |
| Eq HopMessage Source # | |
Defined in Network.LibP2P.NAT.Relay.Message | |
data StopMessage Source #
StopMessage: relay ↔ target.
Constructors
| StopMessage | |
Fields
| |
Instances
| Show StopMessage Source # | |
Defined in Network.LibP2P.NAT.Relay.Message Methods showsPrec :: Int -> StopMessage -> ShowS # show :: StopMessage -> String # showList :: [StopMessage] -> ShowS # | |
| Eq StopMessage Source # | |
Defined in Network.LibP2P.NAT.Relay.Message | |
Status conversion
relayStatusToWord :: RelayStatus -> Word32 Source #
Convert RelayStatus to wire value.
wordToRelayStatus :: Word32 -> Maybe RelayStatus Source #
Convert wire value to RelayStatus.
HopMessage encode/decode
encodeHopMessage :: HopMessage -> ByteString Source #
Encode HopMessage to protobuf (no framing).
decodeHopMessage :: ByteString -> Either ParseError HopMessage Source #
Decode HopMessage from protobuf.
encodeHopFramed :: HopMessage -> ByteString Source #
Encode HopMessage with uvarint length prefix.
decodeHopFramed :: Int -> ByteString -> Either String HopMessage Source #
Decode HopMessage from framed bytes.
writeHopMessage :: StreamIO -> HopMessage -> IO () Source #
Write a framed HopMessage to a stream.
readHopMessage :: StreamIO -> Int -> IO (Either String HopMessage) Source #
Read a framed HopMessage from a stream.
StopMessage encode/decode
encodeStopMessage :: StopMessage -> ByteString Source #
Encode StopMessage to protobuf (no framing).
decodeStopMessage :: ByteString -> Either ParseError StopMessage Source #
Decode StopMessage from protobuf.
encodeStopFramed :: StopMessage -> ByteString Source #
Encode StopMessage with uvarint length prefix.
decodeStopFramed :: Int -> ByteString -> Either String StopMessage Source #
Decode StopMessage from framed bytes.
writeStopMessage :: StreamIO -> StopMessage -> IO () Source #
Write a framed StopMessage to a stream.
readStopMessage :: StreamIO -> Int -> IO (Either String StopMessage) Source #
Read a framed StopMessage from a stream.
Constants
maxRelayMessageSize :: Int Source #
Maximum relay message size: 64 KiB.
hopProtocolId :: Text Source #
Hop protocol identifier.
stopProtocolId :: Text Source #
Stop protocol identifier.