Package marauroa.server.net.validator
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This adds a temporal ban.void
Adds a ban just for this ip address for i seconds.boolean
checkBanned(InetAddress address)
Is the source ip-address banned?void
checks if reload is necessary and performs itvoid
finish()
Request connection validator to stop all the activity, and stop checking if any ban needs to be removed.void
handleDelayedEvent(RPServerManager rpMan, Object data)
handles an delayed eventiterator()
Returns an iterator over the temporal bans.boolean
Removes one of the added temporal bans.Methods 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
-
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
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
This adds a temporal ban.- Parameters:
address
- the address to banmask
- mask to apply to the addresstime
- how many seconds should the ban apply.
-
removeBan
Removes one of the added temporal bans.- Parameters:
address
- the address to removemask
- the mask used.- Returns:
- true if it has been removed.
-
iterator
Returns an iterator over the temporal bans. To access permanent bans, use database facility.- Specified by:
iterator
in interfaceIterable<InetAddressMask>
-
checkBanned
Is the source ip-address banned?- Parameters:
address
- the InetAddress of the source- Returns:
- true if the source ip is banned
-
handleDelayedEvent
Description copied from interface:DelayedEventHandler
handles an delayed event- Specified by:
handleDelayedEvent
in interfaceDelayedEventHandler
- Parameters:
rpMan
- RPServerManagerdata
- some data as defined by the handler
-
checkReload
public void checkReload()checks if reload is necessary and performs it
-