Class FloodValidator

java.lang.Object
marauroa.server.net.flood.FloodValidator
All Implemented Interfaces:
Iterable<FloodMeasure>, IDisconnectedListener

public class FloodValidator extends Object implements IDisconnectedListener, Iterable<FloodMeasure>
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 Details

    • FloodValidator

      public FloodValidator(INetworkServerManager netMan, IFloodCheck check)
      Constructor
      Parameters:
      netMan - INetworkServerManager
      check - the implementation of the flood check.
  • Method Details

    • add

      public void add(Channel channel)
      Adds a new channel to the flood validator.
      Parameters:
      channel - the new added channel.
    • onDisconnect

      public void onDisconnect(Channel channel)
      Callback method. It will be called by NIOServer when the connection is closed.
      Specified by:
      onDisconnect in interface IDisconnectedListener
      Parameters:
      channel - the channel that was closed.
    • isFlooding

      public boolean isFlooding(SocketChannel channel, int length)
      Returns true if the channel passed as param is considered to be flooding
      Parameters:
      channel - the channel we got the new message from
      length - the length in bytes of the message.
      Returns:
      true if it is flooding.
    • onFlood

      public void onFlood(SocketChannel channel)
      This method will call onFlood method of the flood check so appropiate actions can be taken for a flooding channel
      Parameters:
      channel - SocketChannel
    • iterator

      public Iterator<FloodMeasure> iterator()
      Returns an iterator over the flood measure entries.
      Specified by:
      iterator in interface Iterable<FloodMeasure>
      Returns:
      an iterator over the flood measure entries.