Description: This tutorial will show you how to add an anti flood system which allows you to set a amount of connections allowed in a certain time ( Eg. Only allow 10 connections every minute from an IP ), you will easily be able to set the timers yourself and its customizable.
Difficulty: 4/10, probably not even that.
Assumed Knowledge: A little java?
Tested Server: Umm cleaned V4 me thinks.
Files/Classes Modified: The server class
Procedure Step 1: Okay so open your server.java
Declare:
Code:
public java.util.ArrayList<String> bannedHosts = new java.util.ArrayList<String>();
public java.util.HashMap<String, Integer> connectionAmount = new java.util.HashMap<String, Integer>();
public static final int CONNECTION_TIME = 10; /* If sombody connects more than the max attempts within this amount of seconds block them from logging in */
public static final int MAX_CONNECTION_ATTEMPTS = 2;
public static final int BAN_TIME = 30; //4 minutes to keep banned
public int connectionAttempts;
public long connectionTime;
public long timeBanned;
public boolean connectedBefore;
Explanation:
Code:
public java.util.ArrayList<String> bannedHosts = new java.util.ArrayList<String>();
Contains the hosts which are currently banned.
Code:
public java.util.HashMap<String, Integer> connectionAmount = new java.util.HashMap<String, Integer>();
Contains the IP which has connected and the amount of times it has connected within the CONNECTION_TIME time.
Code:
public static final int CONNECTION_TIME = 60;
The time frame in which to allow a certain amount of connections.
Code:
public static final int MAX_CONNECTION_ATTEMPTS = 10;
The max amount of connections allowed within the CONNECTION_TIME time frame.
Code:
public static final int BAN_TIME = 240; //4 minutes to keep banned
If the connecting hosts amount of connections is higher than our max -1 and is not already in tha banned hosts (If they are banned whats the point in doing this) then execute the following code.
Pretty good . Similar with the List and Map with my comments from the other tutorial.
Yeah it is, unfortunately i didn't see your comment on my other thread while I was making this, but like I said there I appritiate your advice and will take on board.
Stupid kid you don't even know what a what a fucking array is your so idiotic its unreal. Get of Rune-server. all you ever do is insult and piss people off.