Package io.netty.handler.codec.haproxy
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:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
public class HAProxyMessageDecoder extends io.netty.handler.codec.ByteToMessageDecoder
Decodes an HAProxy proxy protocol header- See Also:
- Proxy Protocol Specification
-
-
Constructor Summary
Constructors Constructor Description HAProxyMessageDecoder()
Creates 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
protected void
decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out)
static io.netty.handler.codec.ProtocolDetectionResult<HAProxyProtocolVersion>
detectProtocol(io.netty.buffer.ByteBuf buffer)
Returns theProtocolDetectionResult
for the givenByteBuf
.boolean
isSingleDecode()
-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
-
-
-
Constructor Detail
-
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 Detail
-
isSingleDecode
public boolean isSingleDecode()
- Overrides:
isSingleDecode
in classio.netty.handler.codec.ByteToMessageDecoder
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.handler.codec.ByteToMessageDecoder
- Throws:
Exception
-
decode
protected final void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) throws Exception
- Specified by:
decode
in classio.netty.handler.codec.ByteToMessageDecoder
- Throws:
Exception
-
detectProtocol
public static io.netty.handler.codec.ProtocolDetectionResult<HAProxyProtocolVersion> detectProtocol(io.netty.buffer.ByteBuf buffer)
Returns theProtocolDetectionResult
for the givenByteBuf
.
-
-