Class HAProxyMessageDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.haproxy.HAProxyMessageDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Decodes an HAProxy proxy protocol header
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new decoder with no additional data (TLV) restrictions, and should throw an exception as soon as we exceed maxLength.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.HAProxyMessageDecoder(int maxTlvSize) Creates a new decoder with restricted additional data (TLV) size, and should throw an exception as soon as we exceed maxLength.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. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(ChannelHandlerContext ctx, Object msg) CallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.protected final voiddecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Decode the from oneByteBufto an other.detectProtocol(ByteBuf buffer) Returns theProtocolDetectionResultfor the givenByteBuf.booleanIftruethen only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.Methods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
handlerAdded
-
Constructor Details
-
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 headerfailFast- Whether or not to throw an exception as soon as we exceed maxLength
-
-
Method Details
-
isSingleDecode
public boolean isSingleDecode()Description copied from class:ByteToMessageDecoderIftruethen only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call. Default isfalseas this has performance impacts.- Overrides:
isSingleDecodein classByteToMessageDecoder
-
channelRead
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelReadin interfaceChannelInboundHandler- Overrides:
channelReadin classByteToMessageDecoder- Throws:
Exception
-
decode
protected final void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception Description copied from class:ByteToMessageDecoderDecode the from oneByteBufto an other. This method will be called till either the inputByteBufhas nothing to read when return from this method or till nothing was read from the inputByteBuf.- Specified by:
decodein classByteToMessageDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read dataout- theListto which decoded messages should be added- Throws:
Exception- is thrown if an error occurs
-
detectProtocol
Returns theProtocolDetectionResultfor the givenByteBuf.
-