This is the first project I've done in a long time, I started it around 45 minutes ago and already I've come up with a decent base for the project that I will explain as this thread goes along.
So what actually is it? Well simply it just allows for server owners to protect their servers by banning individuals.
You may say "we've had banning for years" and yes that's true, but the banning system I am proposing to create would allow one server owner to ban the user and for them to be banned across EVERY server that is using the banning system.
The advantages of using this type of banning system:
- Can stop hackers or glitchers from attacking multiple servers
- User only needs to be banned once
- Prevents damage to the econemy (bug abusers, dupes etc)
- Makes your server more enjoyable
Okay so now, the disadvantages:
- It could be open to abuse by people who would ban every IP for example, causing distress.
To prevent this disadvantage and make the system as effective as possible I have made the decision that each server will have it's own API key, all ban actions are logged and abuse will have their API key disabled and never reinstated.
Also any disruption because of somebody using their API key in the wrong way is easily reversible due to the fact that each ban is associated with the API key and all bans can be quickly removed.
When to use?
You would only use the banning system for very serious offences, hacking, glitching etc for any other offence you should use your own server banning system.
How would it be used?
Just a simple Java file added to your server sources and one line of code added to where connections are accepted and it works straight out of the box.
If you wish to try the banning system out, please PM me for an API key, please note they will be given to people whom I trust during the beta period and if API keys are released to the public they will be banned.
So the file that you would add, would be this:
Code:
/*
* To change this template, choose Tools | Templates and open the template in
* the editor.
*/
package com.nathanroys.thehammer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Nathan Roys
*/
public class Hammer {
private static final String API_LOC = "http://www.google.com/hammer/api.php";
private static final String API_KEY = "";
/**
* GTFO YOU NO INSTANSIATE ME
*/
private Hammer() {
}
public static boolean isBanned(String ip) {
try {
String response = getResponse("action=check&ip=" + ip);
return Boolean.parseBoolean(response);
} catch (IOException ex) {
Logger.getLogger(Hammer.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
}
public static boolean ban(String ip) {
try {
String response = getResponse("action=add&ip=" + ip);
return response.equals("success");
} catch (IOException ex) {
Logger.getLogger(Hammer.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
}
private static String getResponse(String arguments) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(
new URL(API_LOC + "?api_key=" + API_KEY + "&" + arguments).openStream()));
StringBuilder sb = new StringBuilder();
String s;
while ((s = br.readLine()) != null) {
sb.append(s);
}
br.close();
return sb.toString();
}
}
Simple enough?
And the changelog:
18/02/2012 Project created
18/02/2012 Checking for bans finished
18/02/2012 Adding bans finished
18/02/2012 Api finished, with some bugfixes etc
18/02/2012 Started java backend
18/02/2012 Finished java backend
Thanks for reading..