Package io.netty.handler.address
Class DynamicAddressConnectHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.address.DynamicAddressConnectHandler
- All Implemented Interfaces:
ChannelHandler
,ChannelOutboundHandler
ChannelOutboundHandler
implementation which allows to dynamically replace the used
remoteAddress
and / or localAddress
when making a connection attempt.
This can be useful to for example bind to a specific NetworkInterface
based on
the remoteAddress
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
connect
(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.protected SocketAddress
localAddress
(SocketAddress remoteAddress, SocketAddress localAddress) Returns the localSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
.protected SocketAddress
remoteAddress
(SocketAddress remoteAddress, SocketAddress localAddress) Returns the remoteSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
.Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, deregister, disconnect, flush, read, write
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, 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
exceptionCaught, handlerAdded, handlerRemoved
-
Constructor Details
-
DynamicAddressConnectHandler
public DynamicAddressConnectHandler()
-
-
Method Details
-
connect
public final void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Description copied from class:ChannelOutboundHandlerAdapter
CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
connect
in interfaceChannelOutboundHandler
- Overrides:
connect
in classChannelOutboundHandlerAdapter
- Parameters:
ctx
- theChannelHandlerContext
for which the connect operation is maderemoteAddress
- theSocketAddress
to which it should connectlocalAddress
- theSocketAddress
which is used as source on connectpromise
- theChannelPromise
to notify once the operation completes
-
localAddress
protected SocketAddress localAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception Returns the localSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
. By default, this method returns the givenlocalAddress
.- Throws:
Exception
-
remoteAddress
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception Returns the remoteSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
. By default, this method returns the givenremoteAddress
.- Throws:
Exception
-