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 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 booleanaccept(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress) Called when the channel is connected.voidHandles the specified upstream event.Methods inherited from class 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:IpFilteringHandlerImplCalled when the channel is connected. It returns True if the corresponding connection is to be allowed. Else it returns False.- Specified by:
acceptin classIpFilteringHandlerImpl- Parameters:
inetSocketAddress- the remoteInetSocketAddressfrom client- Returns:
- True if the corresponding connection is allowed, else False.
- Throws:
Exception
-
handleUpstream
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:
Exception
-