Class ConnectionValidator

java.lang.Object
marauroa.server.net.validator.ConnectionValidator
All Implemented Interfaces:
Iterable<InetAddressMask>, DelayedEventHandler

public class ConnectionValidator extends Object implements Iterable<InetAddressMask>, DelayedEventHandler
The ConnectionValidator validates the ariving connections, currently it can only check if the address is banned.

There are two types of bans:

  • Permanent bans
    That are stored at database and that we offer no interface.
  • Temportal bans
    That are not stored but that has a interface for adding, removing and querying bans.
  • Constructor Details

    • ConnectionValidator

      public ConnectionValidator()
      Constructor. It loads permanent bans from database.
  • Method Details

    • finish

      public void finish()
      Request connection validator to stop all the activity, and stop checking if any ban needs to be removed.
    • addBan

      public void addBan(Channel channel, int time)
      Adds a ban just for this ip address for i seconds.
      Parameters:
      channel - the channel whose IP we are going to ban.
      time - how many seconds to ban.
    • addBan

      public void addBan(String address, String mask, long time)
      This adds a temporal ban.
      Parameters:
      address - the address to ban
      mask - mask to apply to the address
      time - how many seconds should the ban apply.
    • removeBan

      public boolean removeBan(String address, String mask)
      Removes one of the added temporal bans.
      Parameters:
      address - the address to remove
      mask - the mask used.
      Returns:
      true if it has been removed.
    • iterator

      public Iterator<InetAddressMask> iterator()
      Returns an iterator over the temporal bans. To access permanent bans, use database facility.
      Specified by:
      iterator in interface Iterable<InetAddressMask>
    • checkBanned

      public boolean checkBanned(InetAddress address)
      Is the source ip-address banned?
      Parameters:
      address - the InetAddress of the source
      Returns:
      true if the source ip is banned
    • handleDelayedEvent

      public void handleDelayedEvent(RPServerManager rpMan, Object data)
      Description copied from interface: DelayedEventHandler
      handles an delayed event
      Specified by:
      handleDelayedEvent in interface DelayedEventHandler
      Parameters:
      rpMan - RPServerManager
      data - some data as defined by the handler
    • checkReload

      public void checkReload()
      checks if reload is necessary and performs it