Package io.netty.handler.ipfilter
Class RuleBasedIpFilter
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.ipfilter.AbstractRemoteAddressFilter<java.net.InetSocketAddress>
-
- io.netty.handler.ipfilter.RuleBasedIpFilter
-
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler
@Sharable public class RuleBasedIpFilter extends AbstractRemoteAddressFilter<java.net.InetSocketAddress>
This class allows one to filter newChannels based on theIpFilterRules passed to its constructor. If no rules are provided, all connections will be accepted. If you would like to explicitly take action on rejectedChannels, you should overrideAbstractRemoteAddressFilter.channelRejected(ChannelHandlerContext, SocketAddress).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private IpFilterRule[]rules
-
Constructor Summary
Constructors Constructor Description RuleBasedIpFilter(IpFilterRule... rules)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaccept(ChannelHandlerContext ctx, java.net.InetSocketAddress remoteAddress)This method is called immediately after aChannelgets registered.-
Methods inherited from class io.netty.handler.ipfilter.AbstractRemoteAddressFilter
channelAccepted, channelActive, channelRegistered, channelRejected
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
-
-
-
Field Detail
-
rules
private final IpFilterRule[] rules
-
-
Constructor Detail
-
RuleBasedIpFilter
public RuleBasedIpFilter(IpFilterRule... rules)
-
-
Method Detail
-
accept
protected boolean accept(ChannelHandlerContext ctx, java.net.InetSocketAddress remoteAddress) throws java.lang.Exception
Description copied from class:AbstractRemoteAddressFilterThis method is called immediately after aChannelgets registered.- Specified by:
acceptin classAbstractRemoteAddressFilter<java.net.InetSocketAddress>- Returns:
- Return true if connections from this IP address and port should be accepted. False otherwise.
- Throws:
java.lang.Exception
-
-