Class HAProxyMessageEncoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<HAProxyMessage>
io.netty.handler.codec.haproxy.HAProxyMessageEncoder
- All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
Encodes an HAProxy proxy protocol message
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HAProxyMessageEncoder(package private) static final int(package private) static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidencode(ChannelHandlerContext ctx, HAProxyMessage msg, ByteBuf out) Encode a message into aByteBuf.private static voidencodeChildTlvs(List<HAProxyTLV> haProxyTLVs, ByteBuf out) Encodes a genuine tree of encapsulated TLVs, e.g.private static voidencodeTlv(HAProxyTLV haProxyTLV, ByteBuf out) private static voidencodeTlvs(List<HAProxyTLV> haProxyTLVs, ByteBuf out) Encodes the top-level TLV list as returned byHAProxyMessage.tlvs().private static voidencodeV1(HAProxyMessage msg, ByteBuf out) private static voidencodeV2(HAProxyMessage msg, ByteBuf out) Methods inherited from class MessageToByteEncoder
acceptOutboundMessage, allocateBuffer, isPreferDirect, writeMethods inherited from class ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Field Details
-
V2_VERSION_BITMASK
private static final int V2_VERSION_BITMASK- See Also:
-
UNIX_ADDRESS_BYTES_LENGTH
static final int UNIX_ADDRESS_BYTES_LENGTH- See Also:
-
TOTAL_UNIX_ADDRESS_BYTES_LENGTH
static final int TOTAL_UNIX_ADDRESS_BYTES_LENGTH- See Also:
-
INSTANCE
-
-
Constructor Details
-
HAProxyMessageEncoder
private HAProxyMessageEncoder()
-
-
Method Details
-
encode
Description copied from class:MessageToByteEncoderEncode a message into aByteBuf. This method will be called for each written message that can be handled by this encoder.- Specified by:
encodein classMessageToByteEncoder<HAProxyMessage>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToByteEncoderbelongs tomsg- the message to encodeout- theByteBufinto which the encoded message will be written- Throws:
Exception- is thrown if an error occurs
-
encodeV1
-
encodeV2
-
encodeTlv
-
encodeChildTlvs
Encodes a genuine tree of encapsulated TLVs, e.g. the direct children of aHAProxySSLTLV. UnlikeHAProxyMessage.tlvs(), this list is not a flattened view, so every element must be encoded. -
encodeTlvs
Encodes the top-level TLV list as returned byHAProxyMessage.tlvs(). That list flattens the direct children of anyHAProxySSLTLVinto it for convenience, so those flattened entries must be skipped here: they are already encoded (recursively) as part of their parentHAProxySSLTLV. Encoding them again would both duplicate their bytes on the wire and make the declared TLV length (seeHAProxyMessage.tlvNumBytes()) not match the number of bytes actually written.
-