diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini index 03cfda4efe..237bafbfb0 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini @@ -102,9 +102,10 @@ IpUpdateTime = 0 # Ppimer : 10.1 NetworkList = 192.168.;10.0. -# =============================================================== -# Test server configuration, not to switch on the game server! = -# =============================================================== + +# --------------------------------------------------------------------------- +# Test server configuration, not to switch on the game server! +# --------------------------------------------------------------------------- # Use the GG client authentication # Login server access let the client without GameGuard ForceGGAuth = False @@ -112,3 +113,15 @@ ForceGGAuth = False # Including protection from flood # IMPORTANT: Put True for server security. EnableFloodProtection = True + + +# --------------------------------------------------------------------------- +# Scheduled Login Restart +# --------------------------------------------------------------------------- +# Enable disable scheduled login restart. +# Default: False +LoginRestartSchedule = False + +# Time in hours. +# Default: 24 +LoginRestartTime = 24 diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index 3e42d58640..ae7e764a35 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -130,6 +130,8 @@ public class Config public static int TRADE_PVP_AMOUNT; public static boolean GLOBAL_CHAT_WITH_PVP; public static int GLOBAL_PVP_AMOUNT; + public static boolean LOGIN_SERVER_SCHEDULE_RESTART; + public static long LOGIN_SERVER_SCHEDULE_RESTART_TIME; public static int MAX_CHAT_LENGTH; public static boolean TRADE_CHAT_IS_NOOBLE; public static boolean PRECISE_DROP_CALCULATION; @@ -2839,6 +2841,8 @@ public class Config MYSQL_BIN_PATH = serverSettings.getString("MySqlBinLocation", "C:/xampp/mysql/bin/"); BACKUP_PATH = serverSettings.getString("BackupPath", "../backup/"); BACKUP_DAYS = serverSettings.getInt("BackupDays", 30); + LOGIN_SERVER_SCHEDULE_RESTART = serverSettings.getBoolean("LoginRestartSchedule", false); + LOGIN_SERVER_SCHEDULE_RESTART_TIME = serverSettings.getLong("LoginRestartTime", 24); SHOW_LICENCE = serverSettings.getBoolean("ShowLicence", false); IP_UPDATE_TIME = serverSettings.getInt("IpUpdateTime", 15); FORCE_GGAUTH = serverSettings.getBoolean("ForceGGAuth", false); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java index 06eb57f6f9..812db3d15e 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java @@ -50,20 +50,14 @@ public class LoginServer extends FloodProtectedListener { public static Logger LOGGER = Logger.getLogger(LoginServer.class.getName()); - private static LoginServer _instance; + public static int PROTOCOL_REV = 0x0102; + private static LoginServer INSTANCE; + private Thread _restartLoginServer; private static GameServerListener _gameServerListener; + private final ThreadPoolExecutor _generalPacketsExecutor; private TelnetStatusThread _statusServer; private ServerSocket _serverSocket; - private final ThreadPoolExecutor _generalPacketsExecutor; - - public static int PROTOCOL_REV = 0x0102; - - public static LoginServer getInstance() - { - return _instance; - } - public static void main(String[] args) { // GUI @@ -81,8 +75,8 @@ public class LoginServer extends FloodProtectedListener try { - _instance = new LoginServer(); - _instance.start(); + INSTANCE = new LoginServer(); + INSTANCE.start(); LOGGER.info("Login Server ready on " + Config.LOGIN_BIND_ADDRESS + ":" + Config.PORT_LOGIN); } catch (IOException e) @@ -242,6 +236,14 @@ public class LoginServer extends FloodProtectedListener { LOGGER.config("IP Bans file (" + bannedFile.getName() + ") is missing or is a directory, skipped."); } + + if (Config.LOGIN_SERVER_SCHEDULE_RESTART) + { + LOGGER.info("Scheduled LS restart after " + Config.LOGIN_SERVER_SCHEDULE_RESTART_TIME + " hours"); + _restartLoginServer = new LoginServerRestart(); + _restartLoginServer.setDaemon(true); + _restartLoginServer.start(); + } } public TelnetStatusThread getStatusServer() @@ -296,6 +298,31 @@ public class LoginServer extends FloodProtectedListener } } + class LoginServerRestart extends Thread + { + public LoginServerRestart() + { + setName("LoginServerRestart"); + } + + @Override + public void run() + { + while (!isInterrupted()) + { + try + { + Thread.sleep(Config.LOGIN_SERVER_SCHEDULE_RESTART_TIME * 3600000); + } + catch (InterruptedException e) + { + return; + } + shutdown(true); + } + } + } + public void shutdown(boolean restart) { // Backup database. @@ -341,4 +368,9 @@ public class LoginServer extends FloodProtectedListener { new LoginClient(socket); } + + public static LoginServer getInstance() + { + return INSTANCE; + } } \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/dist/login/config/main/LoginServer.ini b/L2J_Mobius_C6_Interlude/dist/login/config/main/LoginServer.ini index f7c9d40aee..401980f99f 100644 --- a/L2J_Mobius_C6_Interlude/dist/login/config/main/LoginServer.ini +++ b/L2J_Mobius_C6_Interlude/dist/login/config/main/LoginServer.ini @@ -102,9 +102,10 @@ IpUpdateTime = 0 # Ppimer : 10.1 NetworkList = 192.168.;10.0. -# =============================================================== -# Test server configuration, not to switch on the game server! = -# =============================================================== + +# --------------------------------------------------------------------------- +# Test server configuration, not to switch on the game server! +# --------------------------------------------------------------------------- # Use the GG client authentication # Login server access let the client without GameGuard ForceGGAuth = False @@ -113,18 +114,33 @@ ForceGGAuth = False # IMPORTANT: Put True for server security. EnableFloodProtection = True -# ============================================================= + +# --------------------------------------------------------------------------- # Anti Bruteforce protection. (credits RT-Interlude) -# ============================================================= -#Count of trying connection to server, after which will be made checking IP address -#for a possible BrutForce -#Reducing this value will increase the likelihood of false positives -#Increasing this value will reduce the effectiveness of security (more chance find passwords for large accounts) +# --------------------------------------------------------------------------- +# Count of trying connection to server, after which will be made checking IP address +# for a possible BrutForce +# Reducing this value will increase the likelihood of false positives +# Increasing this value will reduce the effectiveness of security (more chance find passwords for large accounts) BrutLogonAttempts = 15 -#The average time (in seconds) between attempts to connect to the server -#Reducing this value will increase the likelihood of false positives -#Increasing this value will reduce the effectiveness of security (more chance find passwords for large accounts) + +# The average time (in seconds) between attempts to connect to the server +# Reducing this value will increase the likelihood of false positives +# Increasing this value will reduce the effectiveness of security (more chance find passwords for large accounts) BrutAvgTime = 30 -#Number of second, for ban IP address, who time BrutAvgTime less specified -#900 second = 15 minute + +# Number of second, for ban IP address, who time BrutAvgTime less specified +# 900 second = 15 minute BrutBanIpTime = 900 + + +# --------------------------------------------------------------------------- +# Scheduled Login Restart +# --------------------------------------------------------------------------- +# Enable disable scheduled login restart. +# Default: False +LoginRestartSchedule = False + +# Time in hours. +# Default: 24 +LoginRestartTime = 24 diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index 5bddc5818b..89b5622ca3 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -134,6 +134,8 @@ public class Config public static int BRUT_AVG_TIME; public static int BRUT_LOGON_ATTEMPTS; public static int BRUT_BAN_IP_TIME; + public static boolean LOGIN_SERVER_SCHEDULE_RESTART; + public static long LOGIN_SERVER_SCHEDULE_RESTART_TIME; public static int MAX_CHAT_LENGTH; public static boolean TRADE_CHAT_IS_NOOBLE; public static boolean PRECISE_DROP_CALCULATION; @@ -2908,6 +2910,8 @@ public class Config BRUT_AVG_TIME = serverSettings.getInt("BrutAvgTime", 30); // in Seconds BRUT_LOGON_ATTEMPTS = serverSettings.getInt("BrutLogonAttempts", 15); BRUT_BAN_IP_TIME = serverSettings.getInt("BrutBanIpTime", 900); // in Seconds + LOGIN_SERVER_SCHEDULE_RESTART = serverSettings.getBoolean("LoginRestartSchedule", false); + LOGIN_SERVER_SCHEDULE_RESTART_TIME = serverSettings.getLong("LoginRestartTime", 24); SHOW_LICENCE = serverSettings.getBoolean("ShowLicence", false); IP_UPDATE_TIME = serverSettings.getInt("IpUpdateTime", 15); FORCE_GGAUTH = serverSettings.getBoolean("ForceGGAuth", false); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginClient.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginClient.java index 459bbb8c12..09d38bb92b 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginClient.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginClient.java @@ -74,12 +74,11 @@ public class LoginClient extends MMOClient> { super(con); _state = LoginClientState.CONNECTED; - final String ip = getConnection().getInetAddress().getHostAddress(); - _ip = ip; + _ip = getConnection().getInetAddress().getHostAddress(); final String[] localip = Config.NETWORK_IP_LIST.split(";"); for (String oneIp : localip) { - if (ip.startsWith(oneIp) || ip.startsWith("127.0")) + if (_ip.startsWith(oneIp) || _ip.startsWith("127.0")) { _usesInternalIP = true; } @@ -92,13 +91,13 @@ public class LoginClient extends MMOClient> _loginCrypt = new LoginCrypt(); _loginCrypt.setKey(_blowfishKey); LoginController.getInstance().addLoginClient(this); + // This checkup must go next to BAN because it can cause decrease ban account time - if (!BruteProtector.canLogin(ip)) + if (!BruteProtector.canLogin(_ip)) { LoginController.getInstance().addBanForAddress(getConnection().getInetAddress(), Config.BRUT_BAN_IP_TIME * 1000); - LOGGER.warning("Drop connection from IP " + ip + " because of BruteForce."); + LOGGER.warning("Drop connection from IP " + _ip + " because of BruteForce."); } - // Closer.getInstance().add(this); } public String getIntetAddress() diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java index f3ba769beb..aca8e57993 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java @@ -46,6 +46,7 @@ public class LoginServer public static final int PROTOCOL_REV = 0x0102; private static LoginServer INSTANCE; + private Thread _restartLoginServer; private GameServerListener _gameServerListener; private SelectorThread _selectorThread; private TelnetStatusThread _statusServer; @@ -113,6 +114,7 @@ public class LoginServer LOGGER.warning("WARNING: The LoginServer bind address is invalid, using all avaliable IPs " + e1); } } + // Load telnet status if (Config.IS_TELNET_ENABLED) { @@ -171,11 +173,39 @@ public class LoginServer // load bannedIps Config.loadBanFile(); + + if (Config.LOGIN_SERVER_SCHEDULE_RESTART) + { + LOGGER.info("Scheduled LS restart after " + Config.LOGIN_SERVER_SCHEDULE_RESTART_TIME + " hours"); + _restartLoginServer = new LoginServerRestart(); + _restartLoginServer.setDaemon(true); + _restartLoginServer.start(); + } } - public GameServerListener getGameServerListener() + class LoginServerRestart extends Thread { - return _gameServerListener; + public LoginServerRestart() + { + setName("LoginServerRestart"); + } + + @Override + public void run() + { + while (!isInterrupted()) + { + try + { + Thread.sleep(Config.LOGIN_SERVER_SCHEDULE_RESTART_TIME * 3600000); + } + catch (InterruptedException e) + { + return; + } + shutdown(true); + } + } } public void shutdown(boolean restart) @@ -190,6 +220,11 @@ public class LoginServer Runtime.getRuntime().exit(restart ? 2 : 0); } + public GameServerListener getGameServerListener() + { + return _gameServerListener; + } + public int getStatus() { return _loginStatus;