Home / Type/ HAProxyProtocolVersion Type — netty Architecture

HAProxyProtocolVersion Type — netty Architecture

Architecture documentation for the HAProxyProtocolVersion type/interface in HAProxyProtocolVersion.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  eace6990_194b_490c_34fc_a745a71b90b7["HAProxyProtocolVersion"]
  cc884324_8afe_674b_fa76_f69f02db7da4["HAProxyProtocolVersion.java"]
  eace6990_194b_490c_34fc_a745a71b90b7 -->|defined in| cc884324_8afe_674b_fa76_f69f02db7da4
  style eace6990_194b_490c_34fc_a745a71b90b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyProtocolVersion.java lines 23–70

public enum HAProxyProtocolVersion {
    /**
     * The ONE proxy protocol version represents a version 1 (human-readable) header.
     */
    V1(VERSION_ONE_BYTE),
    /**
     * The TWO proxy protocol version represents a version 2 (binary) header.
     */
    V2(VERSION_TWO_BYTE);

    /**
     * The highest 4 bits of the protocol version and command byte contain the version
     */
    private static final byte VERSION_MASK = (byte) 0xf0;

    private final byte byteValue;

    /**
     * Creates a new instance
     */
    HAProxyProtocolVersion(byte byteValue) {
        this.byteValue = byteValue;
    }

    /**
     * Returns the {@link HAProxyProtocolVersion} represented by the highest 4 bits of the specified byte.
     *
     * @param verCmdByte protocol version and command byte
     */
    public static HAProxyProtocolVersion valueOf(byte verCmdByte) {
        int version = verCmdByte & VERSION_MASK;
        switch ((byte) version) {
            case VERSION_TWO_BYTE:
                return V2;
            case VERSION_ONE_BYTE:
                return V1;
            default:
                throw new IllegalArgumentException("unknown version: " + version);
        }
    }

    /**
     * Returns the byte value of this version.
     */
    public byte byteValue() {
        return byteValue;
    }
}

Frequently Asked Questions

What is the HAProxyProtocolVersion type?
HAProxyProtocolVersion is a type/interface in the netty codebase, defined in codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyProtocolVersion.java.
Where is HAProxyProtocolVersion defined?
HAProxyProtocolVersion is defined in codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyProtocolVersion.java at line 23.

Analyze Your Own Codebase

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

Try Supermodel Free