Top Description Constructors Methods
io.netty.handler.ipfilter

public abstract Class AbstractRemoteAddressFilter<T extends java.net.SocketAddress>

extends ChannelInboundHandlerAdapter
Class Inheritance
Known Direct Subclasses
io.netty.handler.ipfilter.IpSubnetFilter, io.netty.handler.ipfilter.RuleBasedIpFilter, io.netty.handler.ipfilter.UniqueIpFilter
Imports
io.netty.channel.Channel, .ChannelFuture, .ChannelFutureListener, .ChannelHandlerContext, .ChannelInboundHandlerAdapter, java.net.SocketAddress

This class provides the functionality to either accept or reject new 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.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract boolean

Returns:

Return true if connections from this IP address and port should be accepted. False otherwise.
accept
(ChannelHandlerContext ctx, T remoteAddress)

This method is called immediately after a io.netty.channel.Channel gets registered.

protected void
channelAccepted(ChannelHandlerContext ctx, T remoteAddress)

This method is called if remoteAddress gets accepted by accept(ChannelHandlerContext, SocketAddress).

public void
public void
protected ChannelFuture

Returns:

A ChannelFuture if you perform I/O operations, so that the Channel can be closed once it completes. Null otherwise.
channelRejected
(ChannelHandlerContext ctx, T remoteAddress)

This method is called if remoteAddress gets rejected by accept(ChannelHandlerContext, SocketAddress).

private boolean
Inherited from io.netty.channel.ChannelInboundHandlerAdapter:
channelInactivechannelReadchannelReadCompletechannelUnregisteredchannelWritabilityChangedexceptionCaughtuserEventTriggered

Constructor Detail

AbstractRemoteAddressFilterback to summary
public AbstractRemoteAddressFilter()

Method Detail

acceptback to summary
protected abstract boolean accept(ChannelHandlerContext ctx, T remoteAddress) throws Exception

This method is called immediately after a io.netty.channel.Channel gets registered.

Returns:boolean

Return true if connections from this IP address and port should be accepted. False otherwise.

channelAcceptedback to summary
protected void channelAccepted(ChannelHandlerContext ctx, T remoteAddress)

This method is called if remoteAddress gets accepted by accept(ChannelHandlerContext, SocketAddress). You should override it if you would like to handle (e.g. respond to) accepted addresses.

Annotations
@SuppressWarnings:UnusedParameters
channelActiveback to summary
public void channelActive(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelActive.

Implements io.netty.channel.ChannelInboundHandler.channelActive.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelActive.

Calls ChannelHandlerContext#fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
channelRegisteredback to summary
public void channelRegistered(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelRegistered.

Implements io.netty.channel.ChannelInboundHandler.channelRegistered.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelRegistered.

Calls ChannelHandlerContext#fireChannelRegistered() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
channelRejectedback to summary
protected ChannelFuture channelRejected(ChannelHandlerContext ctx, T remoteAddress)

This method is called if remoteAddress gets rejected by accept(ChannelHandlerContext, SocketAddress). You should override it if you would like to handle (e.g. respond to) rejected addresses.

Returns:ChannelFuture

A ChannelFuture if you perform I/O operations, so that the Channel can be closed once it completes. Null otherwise.

Annotations
@SuppressWarnings:UnusedParameters
handleNewChannelback to summary
private boolean handleNewChannel(ChannelHandlerContext ctx) throws Exception