Home / Class/ HAProxyTLV Class — netty Architecture

HAProxyTLV Class — netty Architecture

Architecture documentation for the HAProxyTLV class in HAProxyTLV.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  efa831b9_c71e_b7e3_06f1_b38b142dcd99["HAProxyTLV"]
  6e642d30_e1eb_c142_dbe5_d22aff262e13["HAProxyTLV.java"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|defined in| 6e642d30_e1eb_c142_dbe5_d22aff262e13
  92f8cba1_556a_2e40_94e9_eced41d4bd1d["totalNumBytes()"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|method| 92f8cba1_556a_2e40_94e9_eced41d4bd1d
  91926e1e_7200_5b1d_48c4_0cb9bff2400c["contentNumBytes()"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|method| 91926e1e_7200_5b1d_48c4_0cb9bff2400c
  111d0c79_f847_f612_c7e9_f0519bd76e1f["HAProxyTLV()"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|method| 111d0c79_f847_f612_c7e9_f0519bd76e1f
  edca6fb4_e772_48ff_523a_292070c1c9e6["Type()"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|method| edca6fb4_e772_48ff_523a_292070c1c9e6
  1a13e1c2_e494_f430_b09e_24bd5d7d6da9["typeByteValue()"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|method| 1a13e1c2_e494_f430_b09e_24bd5d7d6da9
  b88eeb73_6b32_d33a_b68e_1d2c9cf77457["String()"]
  efa831b9_c71e_b7e3_06f1_b38b142dcd99 -->|method| b88eeb73_6b32_d33a_b68e_1d2c9cf77457

Relationship Graph

Source Code

codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyTLV.java lines 31–216

public class HAProxyTLV extends DefaultByteBufHolder {

    private final Type type;
    private final byte typeByteValue;

    /**
     * The size of this tlv in bytes.
     * @return the number of bytes.
     */
    int totalNumBytes() {
        return 3 + contentNumBytes(); // type(1) + length(2) + content
    }

    int contentNumBytes() {
        return content().readableBytes();
    }

    /**
     * The registered types a TLV can have regarding the PROXY protocol 1.5 spec
     */
    public enum Type {
        PP2_TYPE_ALPN,
        PP2_TYPE_AUTHORITY,
        PP2_TYPE_SSL,
        PP2_TYPE_SSL_VERSION,
        PP2_TYPE_SSL_CN,
        PP2_TYPE_NETNS,
        /**
         * A TLV type that is not officially defined in the spec. May be used for nonstandard TLVs
         */
        OTHER;

        /**
         * Returns the {@link Type} for a specific byte value as defined in the PROXY protocol 1.5 spec
         * <p>
         * If the byte value is not an official one, it will return {@link Type#OTHER}.
         *
         * @param byteValue the byte for a type
         *
         * @return the {@link Type} of a TLV
         */
        public static Type typeForByteValue(byte byteValue) {
            switch (byteValue) {
            case 0x01:
                return PP2_TYPE_ALPN;
            case 0x02:
                return PP2_TYPE_AUTHORITY;
            case 0x20:
                return PP2_TYPE_SSL;
            case 0x21:
                return PP2_TYPE_SSL_VERSION;
            case 0x22:
                return PP2_TYPE_SSL_CN;
            case 0x30:
                return PP2_TYPE_NETNS;
            default:
                return OTHER;
            }
        }

        /**
         * Returns the byte value for the {@link Type} as defined in the PROXY protocol 1.5 spec.
         *
         * @param type the {@link Type}
         *
         * @return the byte value of the {@link Type}.
         */
        public static byte byteValueForType(Type type) {
            switch (type) {
            case PP2_TYPE_ALPN:
                return 0x01;
            case PP2_TYPE_AUTHORITY:
                return 0x02;
            case PP2_TYPE_SSL:
                return 0x20;
            case PP2_TYPE_SSL_VERSION:
                return 0x21;
            case PP2_TYPE_SSL_CN:
                return 0x22;
            case PP2_TYPE_NETNS:
                return 0x30;

Frequently Asked Questions

What is the HAProxyTLV class?
HAProxyTLV is a class in the netty codebase, defined in codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyTLV.java.
Where is HAProxyTLV defined?
HAProxyTLV is defined in codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyTLV.java at line 31.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free