Project update.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler.GameServerState;
|
||||
import com.l2jmobius.util.crypt.NewCrypt;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class BlowFishKey extends BaseRecievePacket
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(BlowFishKey.class.getName());
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public BlowFishKey(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
final int size = readD();
|
||||
final byte[] tempKey = readB(size);
|
||||
try
|
||||
{
|
||||
byte[] tempDecryptKey;
|
||||
final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
|
||||
rsaCipher.init(Cipher.DECRYPT_MODE, server.getPrivateKey());
|
||||
tempDecryptKey = rsaCipher.doFinal(tempKey);
|
||||
// there are nulls before the key we must remove them
|
||||
int i = 0;
|
||||
final int len = tempDecryptKey.length;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
if (tempDecryptKey[i] != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
final byte[] key = new byte[len - i];
|
||||
System.arraycopy(tempDecryptKey, i, key, 0, len - i);
|
||||
|
||||
server.SetBlowFish(new NewCrypt(key));
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("New BlowFish key received, Blowfih Engine initialized:");
|
||||
}
|
||||
server.setLoginConnectionState(GameServerState.BF_CONNECTED);
|
||||
}
|
||||
catch (GeneralSecurityException e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error While decrypting blowfish key (RSA): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.loginserver.LoginController;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ChangeAccessLevel extends BaseRecievePacket
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(ChangeAccessLevel.class.getName());
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public ChangeAccessLevel(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
final int level = readD();
|
||||
final String account = readS();
|
||||
|
||||
LoginController.getInstance().setAccountAccessLevel(account, level);
|
||||
_log.info("Changed " + account + " access level to " + level);
|
||||
}
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.loginserver.GameServerTable;
|
||||
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
*/
|
||||
public class ChangePassword extends BaseRecievePacket
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(ChangePassword.class.getName());
|
||||
private static GameServerThread gst = null;
|
||||
|
||||
public ChangePassword(byte[] decrypt)
|
||||
{
|
||||
super(decrypt);
|
||||
|
||||
final String accountName = readS();
|
||||
final String characterName = readS();
|
||||
final String curpass = readS();
|
||||
final String newpass = readS();
|
||||
|
||||
// get the GameServerThread
|
||||
final Collection<GameServerInfo> serverList = GameServerTable.getInstance().getRegisteredGameServers().values();
|
||||
for (GameServerInfo gsi : serverList)
|
||||
{
|
||||
if ((gsi.getGameServerThread() != null) && gsi.getGameServerThread().hasAccountOnGameServer(accountName))
|
||||
{
|
||||
gst = gsi.getGameServerThread();
|
||||
}
|
||||
}
|
||||
|
||||
if (gst == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((curpass == null) || (newpass == null))
|
||||
{
|
||||
gst.ChangePasswordResponse((byte) 0, characterName, "Invalid password data! Try again.");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA");
|
||||
|
||||
byte[] raw = curpass.getBytes("UTF-8");
|
||||
raw = md.digest(raw);
|
||||
final String curpassEnc = Base64.getEncoder().encodeToString(raw);
|
||||
String pass = null;
|
||||
int passUpdated = 0;
|
||||
|
||||
// SQL connection
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT password FROM accounts WHERE login=?"))
|
||||
{
|
||||
ps.setString(1, accountName);
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
if (rs.next())
|
||||
{
|
||||
pass = rs.getString("password");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curpassEnc.equals(pass))
|
||||
{
|
||||
byte[] password = newpass.getBytes("UTF-8");
|
||||
password = md.digest(password);
|
||||
|
||||
// SQL connection
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET password=? WHERE login=?"))
|
||||
{
|
||||
ps.setString(1, Base64.getEncoder().encodeToString(password));
|
||||
ps.setString(2, accountName);
|
||||
passUpdated = ps.executeUpdate();
|
||||
}
|
||||
|
||||
_log.log(Level.INFO, "The password for account " + accountName + " has been changed from " + curpassEnc + " to " + Base64.getEncoder().encodeToString(password));
|
||||
if (passUpdated > 0)
|
||||
{
|
||||
gst.ChangePasswordResponse((byte) 1, characterName, "You have successfully changed your password!");
|
||||
}
|
||||
else
|
||||
{
|
||||
gst.ChangePasswordResponse((byte) 0, characterName, "The password change was unsuccessful!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gst.ChangePasswordResponse((byte) 0, characterName, "The typed current password doesn't match with your current one.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("Error while changing password for account " + accountName + " requested by player " + characterName + "! " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.loginserver.GameServerTable;
|
||||
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler.GameServerState;
|
||||
import com.l2jmobius.loginserver.network.loginserverpackets.AuthResponse;
|
||||
import com.l2jmobius.loginserver.network.loginserverpackets.LoginServerFail;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Format: cccddb
|
||||
* c desired ID
|
||||
* c accept alternative ID
|
||||
* c reserve Host
|
||||
* s ExternalHostName
|
||||
* s InetranlHostName
|
||||
* d max players
|
||||
* d hexid size
|
||||
* b hexid
|
||||
* </pre>
|
||||
*
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class GameServerAuth extends BaseRecievePacket
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(GameServerAuth.class.getName());
|
||||
GameServerThread _server;
|
||||
private final byte[] _hexId;
|
||||
private final int _desiredId;
|
||||
@SuppressWarnings("unused")
|
||||
private final boolean _hostReserved;
|
||||
private final boolean _acceptAlternativeId;
|
||||
private final int _maxPlayers;
|
||||
private final int _port;
|
||||
private final String[] _hosts;
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public GameServerAuth(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
_server = server;
|
||||
_desiredId = readC();
|
||||
_acceptAlternativeId = (readC() == 0 ? false : true);
|
||||
_hostReserved = (readC() == 0 ? false : true);
|
||||
_port = readH();
|
||||
_maxPlayers = readD();
|
||||
int size = readD();
|
||||
_hexId = readB(size);
|
||||
size = 2 * readD();
|
||||
_hosts = new String[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
_hosts[i] = readS();
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Auth request received");
|
||||
}
|
||||
|
||||
if (handleRegProcess())
|
||||
{
|
||||
final AuthResponse ar = new AuthResponse(server.getGameServerInfo().getId());
|
||||
server.sendPacket(ar);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Authed: id: " + server.getGameServerInfo().getId());
|
||||
}
|
||||
server.broadcastToTelnet("GameServer [" + server.getServerId() + "] " + GameServerTable.getInstance().getServerNameById(server.getServerId()) + " is connected");
|
||||
server.setLoginConnectionState(GameServerState.AUTHED);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleRegProcess()
|
||||
{
|
||||
final GameServerTable gameServerTable = GameServerTable.getInstance();
|
||||
|
||||
final int id = _desiredId;
|
||||
final byte[] hexId = _hexId;
|
||||
|
||||
GameServerInfo gsi = gameServerTable.getRegisteredGameServerById(id);
|
||||
// is there a gameserver registered with this id?
|
||||
if (gsi != null)
|
||||
{
|
||||
// does the hex id match?
|
||||
if (Arrays.equals(gsi.getHexId(), hexId))
|
||||
{
|
||||
// check to see if this GS is already connected
|
||||
synchronized (gsi)
|
||||
{
|
||||
if (gsi.isAuthed())
|
||||
{
|
||||
_server.forceClose(LoginServerFail.REASON_ALREADY_LOGGED8IN);
|
||||
return false;
|
||||
}
|
||||
_server.attachGameServerInfo(gsi, _port, _hosts, _maxPlayers);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is already a server registered with the desired id and different hex id
|
||||
// try to register this one with an alternative id
|
||||
if (Config.ACCEPT_NEW_GAMESERVER && _acceptAlternativeId)
|
||||
{
|
||||
gsi = new GameServerInfo(id, hexId, _server);
|
||||
if (gameServerTable.registerWithFirstAvailableId(gsi))
|
||||
{
|
||||
_server.attachGameServerInfo(gsi, _port, _hosts, _maxPlayers);
|
||||
gameServerTable.registerServerOnDB(gsi);
|
||||
}
|
||||
else
|
||||
{
|
||||
_server.forceClose(LoginServerFail.REASON_NO_FREE_ID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// server id is already taken, and we cant get a new one for you
|
||||
_server.forceClose(LoginServerFail.REASON_WRONG_HEXID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// can we register on this id?
|
||||
if (Config.ACCEPT_NEW_GAMESERVER)
|
||||
{
|
||||
gsi = new GameServerInfo(id, hexId, _server);
|
||||
if (gameServerTable.register(id, gsi))
|
||||
{
|
||||
_server.attachGameServerInfo(gsi, _port, _hosts, _maxPlayers);
|
||||
gameServerTable.registerServerOnDB(gsi);
|
||||
}
|
||||
else
|
||||
{
|
||||
// some one took this ID meanwhile
|
||||
_server.forceClose(LoginServerFail.REASON_ID_RESERVED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_server.forceClose(LoginServerFail.REASON_WRONG_HEXID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.loginserver.LoginController;
|
||||
import com.l2jmobius.loginserver.SessionKey;
|
||||
import com.l2jmobius.loginserver.network.loginserverpackets.PlayerAuthResponse;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerAuthRequest extends BaseRecievePacket
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(PlayerAuthRequest.class.getName());
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public PlayerAuthRequest(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
final String account = readS();
|
||||
final int playKey1 = readD();
|
||||
final int playKey2 = readD();
|
||||
final int loginKey1 = readD();
|
||||
final int loginKey2 = readD();
|
||||
final SessionKey sessionKey = new SessionKey(loginKey1, loginKey2, playKey1, playKey2);
|
||||
|
||||
PlayerAuthResponse authResponse;
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("auth request received for Player " + account);
|
||||
}
|
||||
final SessionKey key = LoginController.getInstance().getKeyForAccount(account);
|
||||
if ((key != null) && key.equals(sessionKey))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("auth request: OK");
|
||||
}
|
||||
LoginController.getInstance().removeAuthedLoginClient(account);
|
||||
authResponse = new PlayerAuthResponse(account, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("auth request: NO");
|
||||
_log.info("session key from self: " + key);
|
||||
_log.info("session key sent: " + sessionKey);
|
||||
}
|
||||
authResponse = new PlayerAuthResponse(account, false);
|
||||
}
|
||||
server.sendPacket(authResponse);
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.loginserver.GameServerTable;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerInGame extends BaseRecievePacket
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(PlayerInGame.class.getName());
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public PlayerInGame(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
final int size = readH();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final String account = readS();
|
||||
server.addAccountOnGameServer(account);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Account " + account + " logged in GameServer: [" + server.getServerId() + "] " + GameServerTable.getInstance().getServerNameById(server.getServerId()));
|
||||
}
|
||||
server.broadcastToTelnet("Account " + account + " logged in GameServer " + server.getServerId());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.loginserver.GameServerTable;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerLogout extends BaseRecievePacket
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(PlayerLogout.class.getName());
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public PlayerLogout(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
final String account = readS();
|
||||
|
||||
server.removeAccountOnGameServer(account);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Player " + account + " logged out from gameserver [" + server.getServerId() + "] " + GameServerTable.getInstance().getServerNameById(server.getServerId()));
|
||||
}
|
||||
|
||||
server.broadcastToTelnet("Player " + account + " disconnected from GameServer " + server.getServerId());
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.loginserver.LoginController;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author mrTJO
|
||||
*/
|
||||
public class PlayerTracert extends BaseRecievePacket
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(PlayerTracert.class.getName());
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
*/
|
||||
public PlayerTracert(byte[] decrypt)
|
||||
{
|
||||
super(decrypt);
|
||||
final String account = readS();
|
||||
final String pcIp = readS();
|
||||
final String hop1 = readS();
|
||||
final String hop2 = readS();
|
||||
final String hop3 = readS();
|
||||
final String hop4 = readS();
|
||||
|
||||
LoginController.getInstance().setAccountLastTracert(account, pcIp, hop1, hop2, hop3, hop4);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Saved " + account + " last tracert");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.loginserver.LoginController;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* Thanks to mochitto.
|
||||
* @author mrTJO
|
||||
*/
|
||||
public class ReplyCharacters extends BaseRecievePacket
|
||||
{
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public ReplyCharacters(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
final String account = readS();
|
||||
final int chars = readC();
|
||||
final int charsToDel = readC();
|
||||
final long[] charsList = new long[charsToDel];
|
||||
for (int i = 0; i < charsToDel; i++)
|
||||
{
|
||||
charsList[i] = readQ();
|
||||
}
|
||||
LoginController.getInstance().setCharactersOnServer(account, chars, charsList, server.getServerId());
|
||||
}
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.loginserver.LoginController;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author mrTJO
|
||||
*/
|
||||
public class RequestTempBan extends BaseRecievePacket
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(RequestTempBan.class.getName());
|
||||
|
||||
private final String _accountName;
|
||||
@SuppressWarnings("unused")
|
||||
private String _banReason;
|
||||
private final String _ip;
|
||||
long _banTime;
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
*/
|
||||
public RequestTempBan(byte[] decrypt)
|
||||
{
|
||||
super(decrypt);
|
||||
_accountName = readS();
|
||||
_ip = readS();
|
||||
_banTime = readQ();
|
||||
final boolean haveReason = readC() == 0 ? false : true;
|
||||
if (haveReason)
|
||||
{
|
||||
_banReason = readS();
|
||||
}
|
||||
banUser();
|
||||
}
|
||||
|
||||
private void banUser()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO account_data VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value=?"))
|
||||
{
|
||||
ps.setString(1, _accountName);
|
||||
ps.setString(2, "ban_temp");
|
||||
ps.setString(3, Long.toString(_banTime));
|
||||
ps.setString(4, Long.toString(_banTime));
|
||||
ps.execute();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LoginController.getInstance().addBanForAddress(_ip, _banTime);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.loginserver.GameServerTable;
|
||||
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ServerStatus extends BaseRecievePacket
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(ServerStatus.class.getName());
|
||||
|
||||
public static final int SERVER_LIST_STATUS = 0x01;
|
||||
public static final int SERVER_TYPE = 0x02;
|
||||
public static final int SERVER_LIST_SQUARE_BRACKET = 0x03;
|
||||
public static final int MAX_PLAYERS = 0x04;
|
||||
public static final int TEST_SERVER = 0x05;
|
||||
public static final int SERVER_AGE = 0x06;
|
||||
|
||||
// Server Status
|
||||
public static final int STATUS_AUTO = 0x00;
|
||||
public static final int STATUS_GOOD = 0x01;
|
||||
public static final int STATUS_NORMAL = 0x02;
|
||||
public static final int STATUS_FULL = 0x03;
|
||||
public static final int STATUS_DOWN = 0x04;
|
||||
public static final int STATUS_GM_ONLY = 0x05;
|
||||
|
||||
// Server Types
|
||||
public static final int SERVER_NORMAL = 0x01;
|
||||
public static final int SERVER_RELAX = 0x02;
|
||||
public static final int SERVER_TEST = 0x04;
|
||||
public static final int SERVER_NOLABEL = 0x08;
|
||||
public static final int SERVER_CREATION_RESTRICTED = 0x10;
|
||||
public static final int SERVER_EVENT = 0x20;
|
||||
public static final int SERVER_FREE = 0x40;
|
||||
|
||||
// Server Ages
|
||||
public static final int SERVER_AGE_ALL = 0x00;
|
||||
public static final int SERVER_AGE_15 = 0x0F;
|
||||
public static final int SERVER_AGE_18 = 0x12;
|
||||
|
||||
public static final int ON = 0x01;
|
||||
public static final int OFF = 0x00;
|
||||
|
||||
/**
|
||||
* @param decrypt
|
||||
* @param server
|
||||
*/
|
||||
public ServerStatus(byte[] decrypt, GameServerThread server)
|
||||
{
|
||||
super(decrypt);
|
||||
|
||||
final GameServerInfo gsi = GameServerTable.getInstance().getRegisteredGameServerById(server.getServerId());
|
||||
if (gsi != null)
|
||||
{
|
||||
final int size = readD();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final int type = readD();
|
||||
final int value = readD();
|
||||
switch (type)
|
||||
{
|
||||
case SERVER_LIST_STATUS:
|
||||
{
|
||||
gsi.setStatus(value);
|
||||
break;
|
||||
}
|
||||
case SERVER_LIST_SQUARE_BRACKET:
|
||||
{
|
||||
gsi.setShowingBrackets(value == ON);
|
||||
break;
|
||||
}
|
||||
case MAX_PLAYERS:
|
||||
{
|
||||
gsi.setMaxPlayers(value);
|
||||
break;
|
||||
}
|
||||
case SERVER_TYPE:
|
||||
{
|
||||
gsi.setServerType(value);
|
||||
break;
|
||||
}
|
||||
case SERVER_AGE:
|
||||
{
|
||||
gsi.setAgeLimit(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user