I hate to be a complete douche but I think that is a horrible idea.
I have never liked the idea of granting banned users any form of connection at all.
Code:
private String[] bannedHosts;
Code:
loadBannedHosts("BANNEDHOSTS.DAT");//the file in which ipbans are stored
if(checkBanned(s.getInetAddress().getHostAddress()))
{
System.out.println("Banned client connecting from " + hostAddress);
s = null;
return;
}
Code:
private boolean checkBanned(String hostName)
{
if(hostName == null)
{
return true;
}
for(int i = 0; i < bannedHosts.length; i++)
{
if(bannedHosts[i] != null && hostName.equals(bannedHosts[i]))
{
return true;
}
}
return false;
}
private void loadBannedHosts(String file)
{
bannedHosts = new String[255];//Adjust this as needed =\
int index = 0;
try
{
BufferedReader in = new BufferedReader(new FileReader(file));
String loggedIPs = null;
while ((loggedIPs = in.readLine()) != null)
{
bannedHosts[index] = loggedIPs;
index++;
}
}
catch(IOException ioe)
{
System.out.println("Error loading banned hosts list.");
}
}