@ChannelHandler.Sharable public class RuleBasedIpFilter extends AbstractRemoteAddressFilter<InetSocketAddress>
This class allows one to filter new Channels based on the
IpFilterRules passed to its constructor. If no rules are provided, all connections
will be accepted.
If you would like to explicitly take action on rejected Channels, you should override
AbstractRemoteAddressFilter.channelRejected(ChannelHandlerContext, SocketAddress).
Consider using IpSubnetFilter for better performance while not as
general purpose as this filter.
ChannelHandler.Sharable| Constructor and Description |
|---|
RuleBasedIpFilter(boolean acceptIfNotFound,
IpFilterRule... rules)
Create new Instance of
RuleBasedIpFilter and filter incoming connections
based on their IP address and rules applied. |
RuleBasedIpFilter(IpFilterRule... rules)
Create new Instance of
RuleBasedIpFilter and filter incoming connections
based on their IP address and rules applied. |
| 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 RuleBasedIpFilter(IpFilterRule... rules)
Create new Instance of RuleBasedIpFilter and filter incoming connections
based on their IP address and rules applied.
acceptIfNotFound is set to true.
rules - An array of IpFilterRule containing all rules.public RuleBasedIpFilter(boolean acceptIfNotFound,
IpFilterRule... rules)
RuleBasedIpFilter and filter incoming connections
based on their IP address and rules applied.acceptIfNotFound - If true then accept connection from IP Address if it
doesn't match any rule.rules - An array of IpFilterRule containing all rules.protected boolean accept(ChannelHandlerContext ctx, InetSocketAddress remoteAddress) throws Exception
AbstractRemoteAddressFilterChannel gets registered.accept in class AbstractRemoteAddressFilter<InetSocketAddress>ExceptionCopyright © 2008–2025 The Netty Project. All rights reserved.