Addition of loginserver restart schedule configurations.

This commit is contained in:
MobiusDevelopment
2020-08-18 11:48:43 +00:00
parent 8f590fdf00
commit 22df83fdea
7 changed files with 140 additions and 37 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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)
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)
BrutAvgTime = 30
# 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

View File

@@ -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);

View File

@@ -74,12 +74,11 @@ public class LoginClient extends MMOClient<MMOConnection<LoginClient>>
{
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<MMOConnection<LoginClient>>
_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()

View File

@@ -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<LoginClient> _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;