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
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.
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
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<InetAddress, Boolean> HashMap of current remote connected InetAddress -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
accept
(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress) Called when the channel is connected.void
Handles the specified upstream event.Methods inherited from class org.jboss.netty.handler.ipfilter.IpFilteringHandlerImpl
continues, handleAllowedChannel, handleRefusedChannel, isBlocked, removeIpFilterListener, setIpFilterListener
-
Field Details
-
connectedSet
HashMap of current remote connected InetAddress
-
-
Constructor Details
-
OneIpFilterHandler
public OneIpFilterHandler()
-
-
Method Details
-
accept
protected boolean accept(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress) throws Exception Description copied from class:IpFilteringHandlerImpl
Called when the channel is connected. It returns True if the corresponding connection is to be allowed. Else it returns False.- Specified by:
accept
in classIpFilteringHandlerImpl
- Parameters:
inetSocketAddress
- the remoteInetSocketAddress
from client- Returns:
- True if the corresponding connection is allowed, else False.
- Throws:
Exception
-
handleUpstream
Description copied from interface:ChannelUpstreamHandler
Handles the specified upstream event.- Specified by:
handleUpstream
in interfaceChannelUpstreamHandler
- Overrides:
handleUpstream
in classIpFilteringHandlerImpl
- Parameters:
ctx
- the context object for this handlere
- the upstream event to process or intercept- Throws:
Exception
-