Game and Login server thread cleanups.
This commit is contained in:
@@ -400,21 +400,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -451,19 +442,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -484,15 +465,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -502,15 +475,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -521,15 +486,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -540,15 +497,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -617,53 +566,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,16 +642,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -710,16 +652,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -731,15 +666,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -400,21 +400,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -451,19 +442,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -484,15 +465,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -502,15 +475,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -521,15 +486,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -540,15 +497,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -617,53 +566,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,16 +642,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -710,16 +652,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -731,15 +666,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.model.World;
|
import org.l2jmobius.gameserver.model.World;
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
import org.l2jmobius.gameserver.model.actor.Player;
|
||||||
@@ -361,21 +362,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -412,19 +404,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addGameServerLogin(String account, GameClient client)
|
public boolean addGameServerLogin(String account, GameClient client)
|
||||||
@@ -449,14 +431,7 @@ public class LoginServerThread extends Thread
|
|||||||
|
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String hexToString(byte[] hex)
|
private String hexToString(byte[] hex)
|
||||||
@@ -498,39 +473,47 @@ public class LoginServerThread extends Thread
|
|||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,16 +543,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||||
import org.l2jmobius.loginserver.network.gameserverpackets.BlowFishKey;
|
import org.l2jmobius.loginserver.network.gameserverpackets.BlowFishKey;
|
||||||
import org.l2jmobius.loginserver.network.gameserverpackets.ChangeAccessLevel;
|
import org.l2jmobius.loginserver.network.gameserverpackets.ChangeAccessLevel;
|
||||||
@@ -392,37 +393,34 @@ public class GameServerThread extends Thread
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void sendPacket(AbstractServerPacket packet)
|
||||||
* @param sl
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
private void sendPacket(AbstractServerPacket sl) throws IOException
|
|
||||||
{
|
{
|
||||||
byte[] data = sl.getContent();
|
try
|
||||||
NewCrypt.appendChecksum(data);
|
|
||||||
_blowfish.crypt(data, 0, data.length);
|
|
||||||
|
|
||||||
final int len = data.length + 2;
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(len & 0xff);
|
final byte[] data = packet.getContent();
|
||||||
_out.write((len >> 8) & 0xff);
|
|
||||||
_out.write(data);
|
synchronized (_out)
|
||||||
_out.flush();
|
{
|
||||||
|
NewCrypt.appendChecksum(data);
|
||||||
|
_blowfish.crypt(data, 0, data.length);
|
||||||
|
|
||||||
|
final int len = data.length + 2;
|
||||||
|
_out.write(len & 0xff);
|
||||||
|
_out.write((len >> 8) & 0xff);
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kickPlayer(String account)
|
public void kickPlayer(String account)
|
||||||
{
|
{
|
||||||
final KickPlayer kp = new KickPlayer(account);
|
sendPacket(new KickPlayer(account));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(kp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.model.World;
|
import org.l2jmobius.gameserver.model.World;
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
import org.l2jmobius.gameserver.model.actor.Player;
|
||||||
@@ -362,21 +363,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -413,19 +405,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addGameServerLogin(String account, GameClient client)
|
public boolean addGameServerLogin(String account, GameClient client)
|
||||||
@@ -450,14 +432,7 @@ public class LoginServerThread extends Thread
|
|||||||
|
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String hexToString(byte[] hex)
|
private String hexToString(byte[] hex)
|
||||||
@@ -499,39 +474,47 @@ public class LoginServerThread extends Thread
|
|||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,16 +544,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
@@ -199,6 +200,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -208,6 +210,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -237,18 +240,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -393,21 +393,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,19 +435,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,15 +458,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -495,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -514,15 +479,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -533,15 +490,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,53 +559,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,16 +635,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -703,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -724,15 +659,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -393,21 +393,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,19 +435,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,15 +458,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -495,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -514,15 +479,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -533,15 +490,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,53 +559,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,16 +635,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -703,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -724,15 +659,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -393,21 +393,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,19 +435,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,15 +458,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -495,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -514,15 +479,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -533,15 +490,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,53 +559,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,16 +635,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -703,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -724,15 +659,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,21 +402,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,19 +444,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -486,15 +467,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -504,15 +477,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -523,15 +488,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -542,15 +499,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -619,53 +568,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,16 +644,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -712,16 +654,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -733,15 +668,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,21 +402,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,19 +444,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -486,15 +467,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -504,15 +477,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -523,15 +488,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -542,15 +499,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -619,53 +568,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,16 +644,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -712,16 +654,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -733,15 +668,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,21 +403,12 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||||
{
|
{
|
||||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
|
||||||
synchronized (_waitingClients)
|
synchronized (_waitingClients)
|
||||||
{
|
{
|
||||||
_waitingClients.add(wc);
|
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(par);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlayerLogout pl = new PlayerLogout(account);
|
|
||||||
try
|
_accountsInGameServer.remove(account);
|
||||||
{
|
sendPacket(new PlayerLogout(account));
|
||||||
sendPacket(pl);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_accountsInGameServer.remove(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendAccessLevel(String account, int level)
|
public void sendAccessLevel(String account, int level)
|
||||||
{
|
{
|
||||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
sendPacket(new ChangeAccessLevel(account, level));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cal);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendClientTracert(String account, String[] address)
|
public void sendClientTracert(String account, String[] address)
|
||||||
{
|
{
|
||||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(ptc);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendMail(String account, String mailId, String... args)
|
public void sendMail(String account, String mailId, String... args)
|
||||||
{
|
{
|
||||||
final SendMail sem = new SendMail(account, mailId, args);
|
sendPacket(new SendMail(account, mailId, args));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(sem);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendTempBan(String account, String ip, long time)
|
public void sendTempBan(String account, String ip, long time)
|
||||||
{
|
{
|
||||||
final TempBan tbn = new TempBan(account, ip, time);
|
sendPacket(new TempBan(account, ip, time));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(tbn);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
|||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(rec);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send packet.
|
* Send packet.
|
||||||
* @param packet the sendable packet
|
* @param packet the sendable packet
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
*/
|
||||||
private void sendPacket(WritablePacket packet) throws IOException
|
private void sendPacket(WritablePacket packet)
|
||||||
{
|
{
|
||||||
if (_blowfish == null)
|
if (_blowfish == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.write(); // write initial data
|
try
|
||||||
packet.writeInt(0); // reserved for checksum
|
|
||||||
int size = packet.getLength() - 2; // size without header
|
|
||||||
final int padding = size % 8; // padding of 8 bytes
|
|
||||||
if (padding != 0)
|
|
||||||
{
|
{
|
||||||
for (int i = padding; i < 8; i++)
|
packet.write(); // write initial data
|
||||||
|
packet.writeInt(0); // reserved for checksum
|
||||||
|
int size = packet.getLength() - 2; // size without header
|
||||||
|
final int padding = size % 8; // padding of 8 bytes
|
||||||
|
if (padding != 0)
|
||||||
{
|
{
|
||||||
packet.writeByte(0);
|
for (int i = padding; i < 8; i++)
|
||||||
|
{
|
||||||
|
packet.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// size header + encrypted[data + checksum (int) + padding]
|
||||||
|
final byte[] data = packet.getSendableBytes();
|
||||||
|
|
||||||
|
// encrypt
|
||||||
|
size = data.length - 2; // data size without header
|
||||||
|
|
||||||
|
synchronized (_out)
|
||||||
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
|
_out.write(data);
|
||||||
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
// size header + encrypted[data + checksum (int) + padding]
|
|
||||||
final byte[] data = packet.getSendableBytes();
|
|
||||||
|
|
||||||
// encrypt
|
|
||||||
size = data.length - 2; // data size without header
|
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
|
||||||
{
|
{
|
||||||
_out.write(data);
|
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
_out.flush();
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerStatus(int id, int value)
|
public void sendServerStatus(int id, int value)
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(id, value);
|
serverStatus.addAttribute(id, value);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendServerType()
|
public void sendServerType()
|
||||||
{
|
{
|
||||||
final ServerStatus ss = new ServerStatus();
|
final ServerStatus serverStatus = new ServerStatus();
|
||||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||||
try
|
sendPacket(serverStatus);
|
||||||
{
|
|
||||||
sendPacket(ss);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
|||||||
*/
|
*/
|
||||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||||
{
|
{
|
||||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||||
try
|
|
||||||
{
|
|
||||||
sendPacket(cp);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// Ignore.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerStatus()
|
public int getServerStatus()
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||||
import org.l2jmobius.commons.network.WritablePacket;
|
import org.l2jmobius.commons.network.WritablePacket;
|
||||||
|
import org.l2jmobius.commons.util.CommonUtil;
|
||||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
|
||||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||||
|
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
import org.l2jmobius.loginserver.network.loginserverpackets.ChangePasswordResponse;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
_connection = con;
|
_connection = con;
|
||||||
_connectionIp = con.getInetAddress().getHostAddress();
|
_connectionIp = con.getInetAddress().getHostAddress();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_in = _connection.getInputStream();
|
_in = _connection.getInputStream();
|
||||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
|||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
|||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
size = data.length - 2; // data size without header
|
size = data.length - 2; // data size without header
|
||||||
NewCrypt.appendChecksum(data, 2, size);
|
|
||||||
_blowfish.crypt(data, 2, size);
|
|
||||||
|
|
||||||
synchronized (_out)
|
synchronized (_out)
|
||||||
{
|
{
|
||||||
|
NewCrypt.appendChecksum(data, 2, size);
|
||||||
|
_blowfish.crypt(data, 2, size);
|
||||||
|
|
||||||
_out.write(data);
|
_out.write(data);
|
||||||
_out.flush();
|
_out.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOGGER.severe("IOException while sending packet " + packet.getClass().getSimpleName());
|
LOGGER.severe("GameServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||||
|
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user