Package org.jboss.netty.handler.ipfilter
Class OneIpFilterHandler
- java.lang.Object
-
- org.jboss.netty.handler.ipfilter.IpFilteringHandlerImpl
-
- org.jboss.netty.handler.ipfilter.OneIpFilterHandler
-
- All Implemented Interfaces:
ChannelHandler,ChannelUpstreamHandler,IpFilteringHandler
@Sharable public class OneIpFilterHandler extends IpFilteringHandlerImpl
Handler that block any new connection if there are already a currently active channel connected with the same InetAddress (IP).
Take care to not change isBlocked method except if you know what you are doing since it is used to test if the current closed connection is to be removed or not from the map of currently connected channel.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentMap<java.net.InetAddress,java.lang.Boolean>connectedSetHashMap of current remote connected InetAddress
-
Constructor Summary
Constructors Constructor Description OneIpFilterHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaccept(ChannelHandlerContext ctx, ChannelEvent e, java.net.InetSocketAddress inetSocketAddress)Called when the channel is connected.voidhandleUpstream(ChannelHandlerContext ctx, ChannelEvent e)Handles the specified upstream event.-
Methods inherited from class org.jboss.netty.handler.ipfilter.IpFilteringHandlerImpl
continues, handleAllowedChannel, handleRefusedChannel, isBlocked, removeIpFilterListener, setIpFilterListener
-
-
-
-
Method Detail
-
accept
protected boolean accept(ChannelHandlerContext ctx, ChannelEvent e, java.net.InetSocketAddress inetSocketAddress) throws java.lang.Exception
Description copied from class:IpFilteringHandlerImplCalled when the channel is connected. It returns True if the corresponding connection is to be allowed. Else it returns False.- Specified by:
acceptin classIpFilteringHandlerImplinetSocketAddress- the remoteInetSocketAddressfrom client- Returns:
- True if the corresponding connection is allowed, else False.
- Throws:
java.lang.Exception
-
handleUpstream
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
Description copied from interface:ChannelUpstreamHandlerHandles the specified upstream event.- Specified by:
handleUpstreamin interfaceChannelUpstreamHandler- Overrides:
handleUpstreamin classIpFilteringHandlerImpl- Parameters:
ctx- the context object for this handlere- the upstream event to process or intercept- Throws:
java.lang.Exception
-
-