public final class HAProxyMessage
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private HAProxyCommand |
command |
private java.lang.String |
destinationAddress |
private int |
destinationPort |
private HAProxyProtocolVersion |
protocolVersion |
private HAProxyProxiedProtocol |
proxiedProtocol |
private java.lang.String |
sourceAddress |
private int |
sourcePort |
private static HAProxyMessage |
V1_UNKNOWN_MSG
Version 1 proxy protocol message for 'UNKNOWN' proxied protocols.
|
private static HAProxyMessage |
V2_LOCAL_MSG
Version 2 proxy protocol message for local requests.
|
private static HAProxyMessage |
V2_UNKNOWN_MSG
Version 2 proxy protocol message for 'UNKNOWN' proxied protocols.
|
Modifier | Constructor and Description |
---|---|
private |
HAProxyMessage(HAProxyProtocolVersion protocolVersion,
HAProxyCommand command,
HAProxyProxiedProtocol proxiedProtocol,
java.lang.String sourceAddress,
java.lang.String destinationAddress,
int sourcePort,
int destinationPort)
Creates a new instance
|
private |
HAProxyMessage(HAProxyProtocolVersion protocolVersion,
HAProxyCommand command,
HAProxyProxiedProtocol proxiedProtocol,
java.lang.String sourceAddress,
java.lang.String destinationAddress,
java.lang.String sourcePort,
java.lang.String destinationPort)
Creates a new instance
|
Modifier and Type | Method and Description |
---|---|
private static void |
checkAddress(java.lang.String address,
HAProxyProxiedProtocol.AddressFamily addrFamily)
Validate an address (IPv4, IPv6, Unix Socket)
|
private static void |
checkPort(int port)
Validate a UDP/TCP port
|
HAProxyCommand |
command()
Returns the
HAProxyCommand of this HAProxyMessage . |
(package private) static HAProxyMessage |
decodeHeader(ByteBuf header)
Decodes a version 2, binary proxy protocol header.
|
(package private) static HAProxyMessage |
decodeHeader(java.lang.String header)
Decodes a version 1, human-readable proxy protocol header.
|
java.lang.String |
destinationAddress()
Returns the human-readable destination address of this
HAProxyMessage . |
int |
destinationPort()
Returns the UDP/TCP destination port of this
HAProxyMessage . |
private static java.lang.String |
ipBytestoString(ByteBuf header,
int addressLen)
Convert ip address bytes to string representation
|
private static int |
portStringToInt(java.lang.String value)
Convert port to integer
|
HAProxyProtocolVersion |
protocolVersion()
Returns the
HAProxyProtocolVersion of this HAProxyMessage . |
HAProxyProxiedProtocol |
proxiedProtocol()
Returns the
HAProxyProxiedProtocol of this HAProxyMessage . |
java.lang.String |
sourceAddress()
Returns the human-readable source address of this
HAProxyMessage . |
int |
sourcePort()
Returns the UDP/TCP source port of this
HAProxyMessage . |
private static final HAProxyMessage V1_UNKNOWN_MSG
private static final HAProxyMessage V2_UNKNOWN_MSG
private static final HAProxyMessage V2_LOCAL_MSG
private final HAProxyProtocolVersion protocolVersion
private final HAProxyCommand command
private final HAProxyProxiedProtocol proxiedProtocol
private final java.lang.String sourceAddress
private final java.lang.String destinationAddress
private final int sourcePort
private final int destinationPort
private HAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, java.lang.String sourceAddress, java.lang.String destinationAddress, java.lang.String sourcePort, java.lang.String destinationPort)
private HAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, java.lang.String sourceAddress, java.lang.String destinationAddress, int sourcePort, int destinationPort)
static HAProxyMessage decodeHeader(ByteBuf header)
header
- a version 2 proxy protocol headerHAProxyMessage
instanceHAProxyProtocolException
- if any portion of the header is invalidstatic HAProxyMessage decodeHeader(java.lang.String header)
header
- a version 1 proxy protocol headerHAProxyMessage
instanceHAProxyProtocolException
- if any portion of the header is invalidprivate static java.lang.String ipBytestoString(ByteBuf header, int addressLen)
header
- buffer containing ip address bytesaddressLen
- number of bytes to read (4 bytes for IPv4, 16 bytes for IPv6)private static int portStringToInt(java.lang.String value)
value
- the portHAProxyProtocolException
- if port is not a valid integerprivate static void checkAddress(java.lang.String address, HAProxyProxiedProtocol.AddressFamily addrFamily)
address
- human-readable addressaddrFamily
- the HAProxyProxiedProtocol.AddressFamily
to check the address againstHAProxyProtocolException
- if the address is invalidprivate static void checkPort(int port)
port
- the UDP/TCP portHAProxyProtocolException
- if the port is out of range (0-65535 inclusive)public HAProxyProtocolVersion protocolVersion()
HAProxyProtocolVersion
of this HAProxyMessage
.public HAProxyCommand command()
HAProxyCommand
of this HAProxyMessage
.public HAProxyProxiedProtocol proxiedProtocol()
HAProxyProxiedProtocol
of this HAProxyMessage
.public java.lang.String sourceAddress()
HAProxyMessage
.public java.lang.String destinationAddress()
HAProxyMessage
.public int sourcePort()
HAProxyMessage
.public int destinationPort()
HAProxyMessage
.