Class IpSubnetFilter

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler

@Sharable public class IpSubnetFilter extends AbstractRemoteAddressFilter<InetSocketAddress>

This class allows one to filter new Channels based on the IpSubnetFilters passed to its constructor. If no rules are provided, all connections will be accepted since acceptIfNotFound is true by default.

If you would like to explicitly take action on rejected Channels, you should override AbstractRemoteAddressFilter.channelRejected(ChannelHandlerContext, SocketAddress).

Few Points to keep in mind:

  1. Since IpSubnetFilter uses Binary search algorithm, it's a good idea to insert IP addresses in incremental order.
  2. Remove any over-lapping CIDR.