public void handleDelayedEvent(RPServerManager rpMan, Object data) {
try {
LoginCommand command = (LoginCommand) data;
SecuredLoginInfo info = command.getInfo();
/*
* We check that player didn't failed too many time the login, if it
* did, we reject the login request until the block pass.
*/
if (command.getFailReason() == MessageS2CLoginNACK.Reasons.TOO_MANY_TRIES) {
logger.debug("Blocked account for player " + info.username + " and/or address " + info.address);
/* Send player the Login NACK message */
MessageS2CLoginNACK msgLoginNACK = new MessageS2CLoginNACK(command.getChannel(),
MessageS2CLoginNACK.Reasons.TOO_MANY_TRIES);
msgLoginNACK.setProtocolVersion(command.getProtocolVersion());
netMan.sendMessage(msgLoginNACK);
/*
* Disconnect player of server.
*/
netMan.disconnectClient(command.getChannel());
return;
}
/*
* We verify the username and the password to make sure player is
* who he/she says he/she is.
*/
if (command.getFailReason() != null) {
/*
* If the verification fails we send player a NACK and record
* the event
*/
logger.debug("Incorrect username/password for player " + info.username);
stats.add("Players invalid login", 1);
/* Send player the Login NACK message */
if (info.reason == null) {
info.reason = MessageS2CLoginNACK.Reasons.USERNAME_WRONG;
}
MessageS2CLoginNACK msgLoginNACK = new MessageS2CLoginNACK(command.getChannel(),
info.reason);
msgLoginNACK.setProtocolVersion(command.getProtocolVersion());
netMan.sendMessage(msgLoginNACK);
playerContainer.remove(command.getClientid());
return;
}
/*
* We check now the account is not banned or inactive.
*/
if (command.getFailMessage() != null) {
logger.info("Banned/Inactive account for player " + info.username + ": " + command.getFailMessage());
/* Send player the Login NACK message */
MessageS2CLoginMessageNACK msgLoginMessageNACK = new MessageS2CLoginMessageNACK(command.getChannel(), command.getFailMessage());
msgLoginMessageNACK.setProtocolVersion(command.getProtocolVersion());
netMan.sendMessage(msgLoginMessageNACK);
/*
* Disconnect player of server.
*/
netMan.disconnectClient(command.getChannel());
return;
}
/* Now we count the number of connections from this ip-address */
int count = info.countConnectionsFromSameIPAddress(playerContainer);
Configuration conf = Configuration.getConfiguration();
int limit = conf.getInt("parallel_connection_limit", TimeoutConf.PARALLEL_CONNECTION_LIMIT);
if (count > limit) {
String whiteList = "," + conf.get("ip_whitelist", "127.0.0.1") + ",";
if (whiteList.indexOf("," + info.address + ",") < 0) {