diff --git a/GameServer/src/org/moparscape/msc/config/Config.java b/GameServer/src/org/moparscape/msc/config/Config.java
index 8f3b0ce..cabc71d 100644
--- a/GameServer/src/org/moparscape/msc/config/Config.java
+++ b/GameServer/src/org/moparscape/msc/config/Config.java
@@ -18,29 +18,30 @@ public class Config {
public static String MYSQL_USER;
public static String MYSQL_PASS;
+ public static String SERVER_IP, SERVER_NAME, RSCD_HOME, CONF_DIR,
+ SERVER_LOCATION, LS_IP;
- public static String SERVER_IP, SERVER_NAME, RSCD_HOME, CONF_DIR, SERVER_LOCATION, LS_IP;
-
- public static int SERVER_PORT, SERVER_VERSION, MAX_PLAYERS, LS_PORT, SERVER_NUM;
+ public static int SERVER_PORT, SERVER_VERSION, MAX_PLAYERS, LS_PORT,
+ SERVER_NUM;
public static long START_TIME;
-
+
public static boolean members, f2pWildy;
-
+
public static double expRate, subExpRate;
-
+
public static String[] pmods, mods, admins;
- public static String UNUSED_IP;
public static int IP_BAN_REMOVAL_DELAY;
public static int GARBAGE_COLLECT_INTERVAL;
public static int SAVE_INTERVAL;
public static String DATE_FORMAT;
-
+ public static String BLOCK_COMMAND;
+ public static String UNBLOCK_COMMAND;
+
static {
loadEnv();
}
-
/**
* Called to load config settings from the given file
*
@@ -71,28 +72,33 @@ public class Config {
LS_IP = props.getProperty("lsip");
LS_PORT = Integer.parseInt(props.getProperty("lsport"));
SERVER_NUM = Integer.parseInt(props.getProperty("servernum"));
-
-
+
members = Boolean.parseBoolean(props.getProperty("members", "false"));
f2pWildy = Boolean.parseBoolean(props.getProperty("f2pWildy", "true"));
expRate = Double.parseDouble(props.getProperty("expRate"));
subExpRate = Double.parseDouble(props.getProperty("subExpRate"));
-
+
pmods = props.getProperty("pmods").replaceAll(", +", ",").split(",");
mods = props.getProperty("mods").replaceAll(", +", ",").split(",");
admins = props.getProperty("admins").replaceAll(", +", ",").split(",");
-
- UNUSED_IP = props.getProperty("unused-ip");
- IP_BAN_REMOVAL_DELAY = Integer.parseInt(props.getProperty("ip-ban-removal-delay"));
-
- GARBAGE_COLLECT_INTERVAL = Integer.parseInt(props.getProperty("garbage-collect-interval"));
+
+ IP_BAN_REMOVAL_DELAY = Integer.parseInt(props
+ .getProperty("ip-ban-removal-delay"));
+ BLOCK_COMMAND = props.getProperty("block-command");
+ UNBLOCK_COMMAND = props.getProperty("unblock-command");
+
+ GARBAGE_COLLECT_INTERVAL = Integer.parseInt(props
+ .getProperty("garbage-collect-interval"));
SAVE_INTERVAL = Integer.parseInt(props.getProperty("save-interval"));
-
+
DATE_FORMAT = props.getProperty("date-format");
-
+
props.clear();
-
- Constants.GameServer.MOTD = "@yel@Welcome to @whi@" + Config.SERVER_NAME + "@yel@ - World @whi@" + (Config.SERVER_NUM == 0 ? 2 : Config.SERVER_NUM) + " (" + (Config.members ? "P2P" : "F2P") + ")";
+
+ Constants.GameServer.MOTD = "@yel@Welcome to @whi@"
+ + Config.SERVER_NAME + "@yel@ - World @whi@"
+ + (Config.SERVER_NUM == 0 ? 2 : Config.SERVER_NUM) + " ("
+ + (Config.members ? "P2P" : "F2P") + ")";
}
/**
diff --git a/GameServer/src/org/moparscape/msc/gs/connection/filter/OSLevelBlocking.scala b/GameServer/src/org/moparscape/msc/gs/connection/filter/OSLevelBlocking.scala
index 780d274..7184431 100644
--- a/GameServer/src/org/moparscape/msc/gs/connection/filter/OSLevelBlocking.scala
+++ b/GameServer/src/org/moparscape/msc/gs/connection/filter/OSLevelBlocking.scala
@@ -10,36 +10,6 @@ import org.moparscape.msc.config.Config
object OSLevelBlocking {
- private val block_ = {
- println(System.getProperty("os.name"))
- if (System.getProperty("os.name") startsWith "(?i)linux") {
- def b(ip: String) {
- Runtime.getRuntime().exec("sudo route add -host " + ip + " reject")
- }
- b _
- } else {
- // Windows blocking - untested - won't work on Windows 7
- def b(ip: String) {
- Runtime.getRuntime().exec("route ADD " + ip + " MASK 255.255.255.255 " + Config.UNUSED_IP)
- }
- b _
- }
- }
- private val unblock_ = {
- if (System.getProperty("os.name") startsWith "(?i)linux") {
- def u(ip: String) {
- Runtime.getRuntime().exec("sudo route del " + ip + " reject")
- }
- u _
- } else {
- // Windows blocking - untested - won't work on Windows 7
- def b(ip: String) {
- Runtime.getRuntime().exec("route DELETE " + ip)
- }
- b _
- }
- }
-
private val blocked = new CopyOnWriteArrayList[String];
private val events = Server.getServer().getEngine().getEventHandler()
@@ -49,26 +19,21 @@ object OSLevelBlocking {
events.add(new DelayedEvent(null, Config.IP_BAN_REMOVAL_DELAY) {
def run() {
- unblock(ip)
-
+ try {
+ Runtime.getRuntime.exec(Config.UNBLOCK_COMMAND.replaceAll("${ip}", ip));
+ blocked.remove(ip)
+ Logger.println("Unblocked " + ip)
+ } catch {
+ case e: Exception => {
+ Logger.error(e)
+ Logger.println("Failed to unblock " + ip)
+ }
+ }
}
})
- block_(ip)
+ Runtime.getRuntime.exec(Config.BLOCK_COMMAND.replaceAll("${ip}", ip));
blocked.add(ip)
Logger.println("Blocked " + ip)
}
}
-
- def unblock(ip: String) {
- try {
- unblock_(ip)
- blocked.remove(ip)
- Logger.println("Unblocked " + ip)
- } catch {
- case e: Exception => {
- Logger.error(e)
- Logger.println("Failed to unblock " + ip)
- }
- }
- }
}
diff --git a/GameServer/world.xml b/GameServer/world.xml
index 3c0c163..ca7ee78 100644
--- a/GameServer/world.xml
+++ b/GameServer/world.xml
@@ -26,9 +26,9 @@
None
None
-
- 192.168.0.255
1800000
+ sudo route add -host ${ip} reject
+ sudo route del -host ${ip} reject
6000000