Strict HAProxy PROXY protocol v1/v2 codec, streaming decoder, TLV parser, and CRC32C validator for MoonBit.
let policy = DecodePolicy::v2_only()
match decode_v2(input, policy) {
Ok(frame) => println("payload bytes: \{frame.remaining.length()}")
Err(error) => println(error.context)
}pub(all) enum AddressBlock {
NoAddress
Ipv4(Ipv4Endpoints)
Ipv6(Ipv6Endpoints)
UnixAddress(UnixEndpoints)
RawUnsupported(Bytes)
} derive(Debug)pub(all) struct DecodePolicy {
expected_protocol : ExpectedProtocol
max_v1_line_bytes : Int
max_v2_payload_bytes : Int
verify_crc32c : Bool
require_crc32c : Bool
allow_local_command : Bool
allow_unspec : Bool
preserve_unknown_tlvs : Bool
} derive(Debug)pub struct Decoder {
policy : DecodePolicy
buffer : ChunkBuffer
state_value : DecoderState
failure : ProxyError?
} derive(Debug)pub(all) struct GeneratedVector {
name : String
parser : String
data : Bytes
expected_success : Bool
expected_error : String
expected_consumed : Int
expected_remaining_length : Int
expected_family : String
expected_transport : String
}pub(all) struct Ipv4Endpoints {
source_address : Ipv4Address
destination_address : Ipv4Address
source_port : Int
destination_port : Int
} derive(Debug)pub(all) struct Ipv6Endpoints {
source_address : Ipv6Address
destination_address : Ipv6Address
source_port : Int
destination_port : Int
} derive(Debug)pub(all) enum ProxyErrorKind {
NeedMoreData
InvalidPrefix
UnsupportedVersion
InvalidCommand
InvalidFamily
InvalidTransport
InvalidFamilyTransport
InvalidV1Line
V1LineTooLong
MissingCrlf
InvalidIpv4
InvalidIpv6
InvalidPort
InvalidV2Signature
InvalidLength
HeaderTooLarge
TruncatedAddress
TruncatedTlv
InvalidTlv
DuplicateCrc32c
MissingCrc32c
Crc32cMismatch
InvalidSslTlv
PolicyViolation
DecoderAlreadyFinished
DecoderFailed
} derive(Eq, Debug)pub(all) struct ProxyHeader {
version : ProxyVersion
command : Command
family : AddressFamily
transport : Transport
address : AddressBlock
tlvs : Array[RawTlv]
} derive(Debug)fn ProxyHeader::new(version : ProxyVersion, command : Command, family : AddressFamily, transport : Transport, address : AddressBlock, tlvs : Array[RawTlv]) -> Result[ProxyHeader, ProxyError]pub(all) struct VectorMetadata {
name : String
category : String
expected_success : Bool
expected_error : String
expected_consumed : Int
expected_remaining_length : Int
expected_family : String
expected_transport : String
} derive(Debug)fn feed_three_way(input : Bytes, first_cut : Int, second_cut : Int, policy : DecodePolicy) -> DecodeProgressfn parse_tlvs(input : Bytes, offset? : Int, preserve_unknown? : Bool) -> Result[Array[RawTlv], ProxyError]fn vector_metadata(name : String, category : String, expected_success : Bool, expected_error : String, expected_consumed : Int, expected_remaining_length : Int, expected_family : String, expected_transport : String) -> VectorMetadataStrict HAProxy PROXY protocol v1/v2 codec, streaming decoder, TLV parser, and CRC32C validator for MoonBit.