Package marauroa.server.net.flood
Class FloodValidator
java.lang.Object
marauroa.server.net.flood.FloodValidator
- All Implemented Interfaces:
Iterable<FloodMeasure>
,IDisconnectedListener
This class implements a Flood checking for all the connections to server.
What is a flood is implemented at the IFloodCheck interface.
- Author:
- miguel
-
Constructor Summary
ConstructorDescriptionFloodValidator(INetworkServerManager netMan, IFloodCheck check)
Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new channel to the flood validator.boolean
isFlooding(SocketChannel channel, int length)
Returns true if the channel passed as param is considered to be floodingiterator()
Returns an iterator over the flood measure entries.void
onDisconnect(Channel channel)
Callback method.void
onFlood(SocketChannel channel)
This method will call onFlood method of the flood check so appropiate actions can be taken for a flooding channelMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FloodValidator
Constructor- Parameters:
netMan
- INetworkServerManagercheck
- the implementation of the flood check.
-
-
Method Details
-
add
Adds a new channel to the flood validator.- Parameters:
channel
- the new added channel.
-
onDisconnect
Callback method. It will be called by NIOServer when the connection is closed.- Specified by:
onDisconnect
in interfaceIDisconnectedListener
- Parameters:
channel
- the channel that was closed.
-
isFlooding
Returns true if the channel passed as param is considered to be flooding- Parameters:
channel
- the channel we got the new message fromlength
- the length in bytes of the message.- Returns:
- true if it is flooding.
-
onFlood
This method will call onFlood method of the flood check so appropiate actions can be taken for a flooding channel- Parameters:
channel
- SocketChannel
-
iterator
Returns an iterator over the flood measure entries.- Specified by:
iterator
in interfaceIterable<FloodMeasure>
- Returns:
- an iterator over the flood measure entries.
-