Class HAProxyMessage
java.lang.Object
io.netty.util.AbstractReferenceCounted
io.netty.handler.codec.haproxy.HAProxyMessage
- All Implemented Interfaces:
ReferenceCounted
Message container for decoded HAProxy proxy protocol parameters
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HAProxyCommandprivate final Stringprivate final intprivate final ResourceLeakTracker<HAProxyMessage> private static final ResourceLeakDetector<HAProxyMessage> private static final intprivate final HAProxyProtocolVersionprivate final HAProxyProxiedProtocolprivate final Stringprivate final intprivate final List<HAProxyTLV> -
Constructor Summary
ConstructorsModifierConstructorDescriptionHAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, String sourceAddress, String destinationAddress, int sourcePort, int destinationPort) Creates a new instance of HAProxyMessage.HAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, String sourceAddress, String destinationAddress, int sourcePort, int destinationPort, List<? extends HAProxyTLV> tlvs) Creates a new instance of HAProxyMessage.privateHAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, String sourceAddress, String destinationAddress, String sourcePort, String destinationPort) Creates a new instance -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcheckAddress(String address, HAProxyProxiedProtocol.AddressFamily addrFamily) Validate an address (IPv4, IPv6, Unix Socket)private static voidcheckPort(int port, HAProxyProxiedProtocol.AddressFamily addrFamily) Validate the port depending on the addrFamily.command()Returns theHAProxyCommandof thisHAProxyMessage.protected voidCalled onceAbstractReferenceCounted.refCnt()is equals 0.(package private) static HAProxyMessagedecodeHeader(ByteBuf header) Decodes a version 2, binary proxy protocol header.(package private) static HAProxyMessagedecodeHeader(String header) Decodes a version 1, human-readable proxy protocol header.Returns the human-readable destination address of thisHAProxyMessage.intReturns the UDP/TCP destination port of thisHAProxyMessage.private static StringipBytesToString(ByteBuf header, int addressLen) Convert ip address bytes to string representationprivate static intportStringToInt(String value) Convert port to integerReturns theHAProxyProtocolVersionof thisHAProxyMessage.Returns theHAProxyProxiedProtocolof thisHAProxyMessage.private static HAProxyTLVreadNextTLV(ByteBuf header, int nestingLevel) private static List<HAProxyTLV> booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement) Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.retain()Increases the reference count by1.retain(int increment) Increases the reference count by the specifiedincrement.Returns the human-readable source address of thisHAProxyMessageornullif HAProxy performs health check withsend-proxy-v2.intReturns the UDP/TCP source port of thisHAProxyMessage.(package private) inttlvs()Returns a list ofHAProxyTLVor an empty list if no TLVs are present.toString()touch()Records the current access location of this object for debugging purposes.Records the current access location of this object with an additional arbitrary information for debugging purposes.private voidprivate static HAProxyMessageunknownMsg(HAProxyProtocolVersion version, HAProxyCommand command) Proxy protocol message for 'UNKNOWN' proxied protocols.Methods inherited from class AbstractReferenceCounted
refCnt, setRefCnt
-
Field Details
-
MAX_NESTING_LEVEL
private static final int MAX_NESTING_LEVEL- See Also:
-
leakDetector
-
leak
-
protocolVersion
-
command
-
proxiedProtocol
-
sourceAddress
-
destinationAddress
-
sourcePort
private final int sourcePort -
destinationPort
private final int destinationPort -
tlvs
-
-
Constructor Details
-
HAProxyMessage
private HAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, String sourceAddress, String destinationAddress, String sourcePort, String destinationPort) Creates a new instance -
HAProxyMessage
public HAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, String sourceAddress, String destinationAddress, int sourcePort, int destinationPort) Creates a new instance of HAProxyMessage.- Parameters:
protocolVersion- the protocol version.command- the command.proxiedProtocol- the protocol containing the address family and transport protocol.sourceAddress- the source address.destinationAddress- the destination address.sourcePort- the source port. This value must be 0 for unix, unspec addresses.destinationPort- the destination port. This value must be 0 for unix, unspec addresses.
-
HAProxyMessage
public HAProxyMessage(HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol, String sourceAddress, String destinationAddress, int sourcePort, int destinationPort, List<? extends HAProxyTLV> tlvs) Creates a new instance of HAProxyMessage.- Parameters:
protocolVersion- the protocol version.command- the command.proxiedProtocol- the protocol containing the address family and transport protocol.sourceAddress- the source address.destinationAddress- the destination address.sourcePort- the source port. This value must be 0 for unix, unspec addresses.destinationPort- the destination port. This value must be 0 for unix, unspec addresses.tlvs- the list of tlvs.
-
-
Method Details
-
decodeHeader
Decodes a version 2, binary proxy protocol header.- Parameters:
header- a version 2 proxy protocol header- Returns:
HAProxyMessageinstance- Throws:
HAProxyProtocolException- if any portion of the header is invalid
-
readTlvs
-
readNextTLV
-
decodeHeader
Decodes a version 1, human-readable proxy protocol header.- Parameters:
header- a version 1 proxy protocol header- Returns:
HAProxyMessageinstance- Throws:
HAProxyProtocolException- if any portion of the header is invalid
-
unknownMsg
Proxy protocol message for 'UNKNOWN' proxied protocols. Per spec, when the proxied protocol is 'UNKNOWN' we must discard all other header values. -
ipBytesToString
-
portStringToInt
Convert port to integer- Parameters:
value- the port- Returns:
- port as an integer
- Throws:
IllegalArgumentException- if port is not a valid integer
-
checkAddress
Validate an address (IPv4, IPv6, Unix Socket)- Parameters:
address- human-readable addressaddrFamily- theHAProxyProxiedProtocol.AddressFamilyto check the address against- Throws:
IllegalArgumentException- if the address is invalid
-
checkPort
Validate the port depending on the addrFamily.- Parameters:
port- the UDP/TCP port- Throws:
IllegalArgumentException- if the port is out of range (0-65535 inclusive)
-
protocolVersion
Returns theHAProxyProtocolVersionof thisHAProxyMessage. -
command
Returns theHAProxyCommandof thisHAProxyMessage. -
proxiedProtocol
Returns theHAProxyProxiedProtocolof thisHAProxyMessage. -
sourceAddress
Returns the human-readable source address of thisHAProxyMessageornullif HAProxy performs health check withsend-proxy-v2. -
destinationAddress
Returns the human-readable destination address of thisHAProxyMessage. -
sourcePort
public int sourcePort()Returns the UDP/TCP source port of thisHAProxyMessage. -
destinationPort
public int destinationPort()Returns the UDP/TCP destination port of thisHAProxyMessage. -
tlvs
Returns a list ofHAProxyTLVor an empty list if no TLVs are present.TLVs are only available for the Proxy Protocol V2
-
tlvNumBytes
int tlvNumBytes() -
touch
Description copied from interface:ReferenceCountedRecords the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceReferenceCounted- Overrides:
touchin classAbstractReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector. -
retain
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCounted
-
release
public boolean release()Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Overrides:
releasein classAbstractReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement) Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Overrides:
releasein classAbstractReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
tryRecord
private void tryRecord() -
deallocate
protected void deallocate()Description copied from class:AbstractReferenceCountedCalled onceAbstractReferenceCounted.refCnt()is equals 0.- Specified by:
deallocatein classAbstractReferenceCounted
-
toString
-