@ChannelHandler.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:
IpSubnetFilter uses Binary search algorithm, it's a good
idea to insert IP addresses in incremental order. ChannelHandler.Sharable| Constructor and Description |
|---|
IpSubnetFilter(boolean acceptIfNotFound,
IpSubnetFilterRule... rules)
Create new
IpSubnetFilter Instance with specified IpSubnetFilterRule as array
and specify if we'll accept a connection if we don't find it in the rule(s). |
IpSubnetFilter(boolean acceptIfNotFound,
List<IpSubnetFilterRule> rules)
Create new
IpSubnetFilter Instance with specified IpSubnetFilterRule as List
and specify if we'll accept a connection if we don't find it in the rule(s). |
IpSubnetFilter(IpSubnetFilterRule... rules)
Create new
IpSubnetFilter Instance with specified IpSubnetFilterRule as array. |
IpSubnetFilter(List<IpSubnetFilterRule> rules)
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
accept(ChannelHandlerContext ctx,
InetSocketAddress remoteAddress)
This method is called immediately after a
Channel gets registered. |
channelAccepted, channelActive, channelRegistered, channelRejectedchannelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedpublic IpSubnetFilter(IpSubnetFilterRule... rules)
Create new IpSubnetFilter Instance with specified IpSubnetFilterRule as array.
acceptIfNotFound is set to true.
rules - IpSubnetFilterRule as an arraypublic IpSubnetFilter(boolean acceptIfNotFound,
IpSubnetFilterRule... rules)
Create new IpSubnetFilter Instance with specified IpSubnetFilterRule as array
and specify if we'll accept a connection if we don't find it in the rule(s).
acceptIfNotFound - true if we'll accept connection if not found in rule(s).rules - IpSubnetFilterRule as an arraypublic IpSubnetFilter(List<IpSubnetFilterRule> rules)
Create new IpSubnetFilter Instance with specified IpSubnetFilterRule as List.
acceptIfNotFound is set to true.
rules - IpSubnetFilterRule as a Listpublic IpSubnetFilter(boolean acceptIfNotFound,
List<IpSubnetFilterRule> rules)
Create new IpSubnetFilter Instance with specified IpSubnetFilterRule as List
and specify if we'll accept a connection if we don't find it in the rule(s).
acceptIfNotFound - true if we'll accept connection if not found in rule(s).rules - IpSubnetFilterRule as a Listprotected boolean accept(ChannelHandlerContext ctx, InetSocketAddress remoteAddress)
AbstractRemoteAddressFilterChannel gets registered.accept in class AbstractRemoteAddressFilter<InetSocketAddress>Copyright © 2008–2025 The Netty Project. All rights reserved.