public abstract class AbstractRemoteAddressFilter<T extends java.net.SocketAddress> extends ChannelInboundHandlerAdapter
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| 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 ChannelInboundHandler in the ChannelPipeline. |
void |
channelRegistered(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelRegistered() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
protected ChannelFuture |
channelRejected(ChannelHandlerContext ctx,
T remoteAddress)
This method is called if
remoteAddress gets rejected by
accept(ChannelHandlerContext, SocketAddress). |
channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedpublic void channelRegistered(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelRegistered() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelRegistered in interface ChannelInboundHandlerchannelRegistered in class ChannelInboundHandlerAdapterjava.lang.Exceptionpublic void channelActive(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelActive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelActive in interface ChannelInboundHandlerchannelActive in class ChannelInboundHandlerAdapterjava.lang.Exceptionprotected abstract boolean accept(ChannelHandlerContext ctx, T remoteAddress) throws java.lang.Exception
Channel gets registered.java.lang.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–2018 The Netty Project. All rights reserved.