Top Description Constructors Methods
io.netty5.handler.ipfilter

public abstract Class AbstractRemoteAddressFilter<T extends SocketAddress>

extends Object
implements ChannelHandler
Class Inheritance
All Implemented Interfaces
io.netty5.channel.ChannelHandler
Known Direct Subclasses
io.netty5.handler.ipfilter.IpSubnetFilter, io.netty5.handler.ipfilter.RuleBasedIpFilter, io.netty5.handler.ipfilter.UniqueIpFilter
Imports
io.netty5.channel.Channel, .ChannelFutureListeners, .ChannelHandler, .ChannelHandlerContext, io.netty5.util.concurrent.Future, 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.netty5.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 Future<Void>

Returns:

A Future 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
handleNewChannel(ChannelHandlerContext ctx, boolean register)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

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.netty5.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 default io.netty5.channel.ChannelHandler.channelActive.

Doc from io.netty5.channel.ChannelHandler.channelActive.

The Channel of the ChannelHandlerContext is now active

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

Overrides default io.netty5.channel.ChannelHandler.channelRegistered.

Doc from io.netty5.channel.ChannelHandler.channelRegistered.

The Channel of the ChannelHandlerContext was registered with its EventLoop

Annotations
@Override
channelRejectedback to summary
protected Future<Void> 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:Future<Void>

A Future 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, boolean register) throws Exception