PDA

View Full Version : IP Ban and Ban. 508.



Faab234
June 18th, 2010, 14:45
This is the converted version of my (IP) Ban.

FileManager:


/**
* (IP) Ban
*/
private List<String> IPBanned = new ArrayList<String>();
private List<String> BannedUsers = new ArrayList<String>();

public List<String> GetIPBans() {
return IPBanned;
}
public List<String> GetBannedUsers() {
return BannedUsers;
}


/**
* IP Ban */
public static void LoadIPBans() {
try {
BufferedReader in = new BufferedReader(new FileReader("./data/IPBans.dat"));
String line;
while ((line = in.readLine()) != null) {
Engine.fileManager.GetIPBans().add(line.toLowerCas e());
}
} catch (Exception e) {
Misc.println("Error with Loading Banned IP's");
e.printStackTrace();
}
Misc.println(Engine.fileManager.GetIPBans().size() + " Banned IP(s).");
}
/**
* BannedUser
*/
public static void LoadBannedUsers() {
try {
BufferedReader in = new BufferedReader(new FileReader("./Data/BannedUsers.dat"));
String line;
while ((line = in.readLine()) != null) {
Engine.fileManager.GetBannedUsers().add(line.toLow erCase());
}
} catch (Exception e) {
Misc.println("Error with Loading Bannedsers");
e.printStackTrace();
}
Misc.println(Engine.fileManager.GetBannedUsers().s ize() + " Banned Users.");
}


Login.java:


if (Engine.fileManager.GetBannedUsers().contains(p.us ername)) {
returnCode = 4;
}

SocketListener.java:


if (Engine.fileManager.GetIPBans().contains(getAddres s(socket))) {
socket.close();
continue;

}


The Default Palidino76 already have a (IP) ban.

Edit;

FileManager:

Import:


import java.io.*;
import java.util.ListIterator;
import java.util.ArrayList;
import java.util.List;

snkey31
June 18th, 2010, 14:46
Thanks faab helped me

Faab234
June 18th, 2010, 14:49
Thanks Snkey31.

jamie
June 19th, 2010, 05:20
Yay it works :)

Faab234
June 19th, 2010, 09:32
Thanks Jamie.

Nathan'
June 19th, 2010, 09:42
OFC it works. faab posted it :P

girlz ftw
June 23rd, 2010, 09:52
omfg thanks:D