Class HAProxyMessageDecoder

    • Field Detail

      • V1_MAX_LENGTH

        private static final int V1_MAX_LENGTH
        Maximum possible length of a v1 proxy protocol header per spec
        See Also:
        Constant Field Values
      • V2_MAX_LENGTH

        private static final int V2_MAX_LENGTH
        Maximum possible length of a v2 proxy protocol header (fixed 16 bytes + max unsigned short)
        See Also:
        Constant Field Values
      • V2_MIN_LENGTH

        private static final int V2_MIN_LENGTH
        Minimum possible length of a fully functioning v2 proxy protocol header (fixed 16 bytes + v2 address info space)
        See Also:
        Constant Field Values
      • V2_MAX_TLV

        private static final int V2_MAX_TLV
        Maximum possible length for v2 additional TLV data (max unsigned short - max v2 address info space)
        See Also:
        Constant Field Values
      • BINARY_PREFIX_LENGTH

        private static final int BINARY_PREFIX_LENGTH
        Binary header prefix length
      • discarding

        private boolean discarding
        true if we're discarding input because we're already over maxLength
      • discardedBytes

        private int discardedBytes
        Number of discarded bytes
      • failFast

        private final boolean failFast
        Whether or not to throw an exception as soon as we exceed maxLength.
      • finished

        private boolean finished
        true if we're finished decoding the proxy protocol header
      • version

        private int version
        Protocol specification version
      • v2MaxHeaderSize

        private final int v2MaxHeaderSize
        The latest v2 spec (2014/05/18) allows for additional data to be sent in the proxy protocol header beyond the address information block so now we need a configurable max header size
    • Constructor Detail

      • HAProxyMessageDecoder

        public HAProxyMessageDecoder()
        Creates a new decoder with no additional data (TLV) restrictions, and should throw an exception as soon as we exceed maxLength.
      • HAProxyMessageDecoder

        public HAProxyMessageDecoder​(boolean failFast)
        Creates a new decoder with no additional data (TLV) restrictions, whether or not to throw an exception as soon as we exceed maxLength.
        Parameters:
        failFast - Whether or not to throw an exception as soon as we exceed maxLength
      • HAProxyMessageDecoder

        public HAProxyMessageDecoder​(int maxTlvSize)
        Creates a new decoder with restricted additional data (TLV) size, and should throw an exception as soon as we exceed maxLength.

        Note: limiting TLV size only affects processing of v2, binary headers. Also, as allowed by the 1.5 spec TLV data is currently ignored. For maximum performance it would be best to configure your upstream proxy host to NOT send TLV data and instantiate with a max TLV size of 0.

        Parameters:
        maxTlvSize - maximum number of bytes allowed for additional data (Type-Length-Value vectors) in a v2 header
      • HAProxyMessageDecoder

        public HAProxyMessageDecoder​(int maxTlvSize,
                                     boolean failFast)
        Creates a new decoder with restricted additional data (TLV) size, whether or not to throw an exception as soon as we exceed maxLength.
        Parameters:
        maxTlvSize - maximum number of bytes allowed for additional data (Type-Length-Value vectors) in a v2 header
        failFast - Whether or not to throw an exception as soon as we exceed maxLength