public abstract class AbstractRemoteAddressFilter<T extends SocketAddress> extends ChannelHandlerAdapter
Channels
based on their IP address.
You should inherit from this class if you would like to implement your own IP-based filter. Basically you have to
implement accept(ChannelHandlerContext, SocketAddress) to decided whether you want to accept or reject
a connection from the remote address.
Furthermore overriding channelRejected(ChannelHandlerContext, SocketAddress) gives you the
flexibility to respond to rejected (denied) connections. If you do not want to send a response, just have it return
null. Take a look at RuleBasedIpFilter for details.
ChannelHandler.Sharable, ChannelHandler.Skip| Constructor and Description |
|---|
AbstractRemoteAddressFilter() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
accept(ChannelHandlerContext ctx,
T remoteAddress)
This method is called immediately after a
Channel gets registered. |
protected void |
channelAccepted(ChannelHandlerContext ctx,
T remoteAddress)
This method is called if
remoteAddress gets accepted by
accept(ChannelHandlerContext, SocketAddress). |
void |
channelActive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelActive() to forward
to the next ChannelHandler in the ChannelPipeline. |
void |
channelRegistered(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelRegistered() to forward
to the next ChannelHandler in the ChannelPipeline. |
protected ChannelFuture |
channelRejected(ChannelHandlerContext ctx,
T remoteAddress)
This method is called if
remoteAddress gets rejected by
accept(ChannelHandlerContext, SocketAddress). |
bind, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, handlerAdded, handlerRemoved, isSharable, read, userEventTriggered, writepublic void channelRegistered(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterChannelHandlerContext.fireChannelRegistered() to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelRegistered in interface ChannelHandlerchannelRegistered in class ChannelHandlerAdapterExceptionpublic void channelActive(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterChannelHandlerContext.fireChannelActive() to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelActive in interface ChannelHandlerchannelActive in class ChannelHandlerAdapterExceptionprotected abstract boolean accept(ChannelHandlerContext ctx, T remoteAddress) throws Exception
Channel gets registered.Exceptionprotected void channelAccepted(ChannelHandlerContext ctx, T remoteAddress)
remoteAddress gets accepted by
accept(ChannelHandlerContext, SocketAddress). You should override it if you would like to handle
(e.g. respond to) accepted addresses.protected ChannelFuture channelRejected(ChannelHandlerContext ctx, T remoteAddress)
remoteAddress gets rejected by
accept(ChannelHandlerContext, SocketAddress). You should override it if you would like to handle
(e.g. respond to) rejected addresses.ChannelFuture if you perform I/O operations, so that
the Channel can be closed once it completes. Null otherwise.Copyright © 2008–2015 The Netty Project. All rights reserved.