Package com.netflix.netty.common
Class SourceAddressChannelHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.netflix.netty.common.SourceAddressChannelHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
@Sharable
public final class SourceAddressChannelHandler
extends io.netty.channel.ChannelInboundHandlerAdapter
Stores the source IP address as an attribute of the channel. This has the advantage of allowing us to overwrite it if
we have more info (eg. ELB sends a HAProxyMessage with info of REAL source host + port).
User: [email protected] Date: 4/14/16 Time: 4:29 PM
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.netty.util.AttributeKey<SocketAddress>
Indicates the local address of the channel.static final io.netty.util.AttributeKey<String>
The local address of this channel.static final io.netty.util.AttributeKey<InetSocketAddress>
Deprecated.static final io.netty.util.AttributeKey<InetSocketAddress>
Indicates the destination address received from Proxy Protocol.static final io.netty.util.AttributeKey<SocketAddress>
Indicates the actual source (remote) address of the channel.static final io.netty.util.AttributeKey<String>
Deprecated.static final io.netty.util.AttributeKey<Integer>
The port number of the local socket, or-1
if not appropriate.static final io.netty.util.AttributeKey<String>
The host address of the source.static final io.netty.util.AttributeKey<InetSocketAddress>
Deprecated. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
ATTR_REMOTE_ADDR
Indicates the actual source (remote) address of the channel. This can be different than the oneChannel
returns if the connection is being proxied. (e.g. over HAProxy) -
ATTR_PROXY_PROTOCOL_DESTINATION_ADDRESS
public static final io.netty.util.AttributeKey<InetSocketAddress> ATTR_PROXY_PROTOCOL_DESTINATION_ADDRESSIndicates the destination address received from Proxy Protocol. Not set otherwise -
ATTR_SOURCE_INET_ADDR
Deprecated.UseATTR_REMOTE_ADDR
instead. -
ATTR_SOURCE_ADDRESS
The host address of the source. This is derived fromATTR_REMOTE_ADDR
. If the address is an IPv6 address, the scope identifier is absent. -
ATTR_LOCAL_ADDR
Indicates the local address of the channel. This can be different than the oneChannel
returns if the connection is being proxied. (e.g. over HAProxy) -
ATTR_LOCAL_INET_ADDR
Deprecated.UseATTR_LOCAL_ADDR
instead. -
ATTR_LOCAL_ADDRESS
The local address of this channel. This is derived fromchannel.localAddress()
, or from the Proxy Protocol preface if provided. If the address is an IPv6 address, the scope identifier is absent. UnlikeATTR_SERVER_LOCAL_ADDRESS
, this value is overwritten with the Proxy Protocol local address (e.g. the LB's local address), if enabled. -
ATTR_SERVER_LOCAL_ADDRESS
Deprecated.Usechannel.localAddress()
instead.The actual local address of the channel, in string form. If the address is an IPv6 address, the scope identifier is absent. UnlikeATTR_LOCAL_ADDRESS
, this is not overwritten by the Proxy Protocol message if present. -
ATTR_SERVER_LOCAL_PORT
The port number of the local socket, or-1
if not appropriate. This is not overwritten by the Proxy Protocol message if present.
-
-
Constructor Details
-
SourceAddressChannelHandler
public SourceAddressChannelHandler()
-
-
Method Details
-
channelActive
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channel.localAddress()
instead.