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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -451,19 +442,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,15 +465,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,15 +475,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,15 +486,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,15 +497,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -617,53 +566,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,16 +642,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -710,16 +652,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -731,15 +666,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -451,19 +442,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,15 +465,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,15 +475,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,15 +486,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,15 +497,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -617,53 +566,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,16 +642,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -710,16 +652,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -731,15 +666,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,19 +404,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
public boolean addGameServerLogin(String account, GameClient client)
|
||||
@@ -449,14 +431,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
private String hexToString(byte[] hex)
|
||||
@@ -498,39 +473,47 @@ public class LoginServerThread extends Thread
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,16 +543,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.BlowFishKey;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.ChangeAccessLevel;
|
||||
@@ -392,37 +393,34 @@ public class GameServerThread extends Thread
|
||||
start();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sl
|
||||
* @throws IOException
|
||||
*/
|
||||
private void sendPacket(AbstractServerPacket sl) throws IOException
|
||||
private void sendPacket(AbstractServerPacket packet)
|
||||
{
|
||||
byte[] data = sl.getContent();
|
||||
NewCrypt.appendChecksum(data);
|
||||
_blowfish.crypt(data, 0, data.length);
|
||||
|
||||
final int len = data.length + 2;
|
||||
synchronized (_out)
|
||||
try
|
||||
{
|
||||
_out.write(len & 0xff);
|
||||
_out.write((len >> 8) & 0xff);
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
final byte[] data = packet.getContent();
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
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)
|
||||
{
|
||||
final KickPlayer kp = new KickPlayer(account);
|
||||
try
|
||||
{
|
||||
sendPacket(kp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
sendPacket(new KickPlayer(account));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -40,6 +40,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,19 +405,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
public boolean addGameServerLogin(String account, GameClient client)
|
||||
@@ -450,14 +432,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
private String hexToString(byte[] hex)
|
||||
@@ -499,39 +474,47 @@ public class LoginServerThread extends Thread
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,16 +544,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,6 +29,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler.GameServerState;
|
||||
@@ -199,6 +200,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -208,6 +210,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -237,18 +240,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,19 +435,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,15 +458,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,15 +479,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,15 +490,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,53 +559,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,16 +635,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -703,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,15 +659,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,19 +435,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,15 +458,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,15 +479,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,15 +490,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,53 +559,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,16 +635,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -703,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,15 +659,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,19 +435,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,15 +458,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,15 +479,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,15 +490,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,53 +559,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,16 +635,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -703,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,15 +659,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,19 +444,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,15 +467,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,15 +477,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,15 +488,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,15 +499,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -619,53 +568,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,16 +644,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -712,16 +654,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -733,15 +668,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,19 +444,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,15 +467,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,15 +477,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,15 +488,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,15 +499,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -619,53 +568,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,16 +644,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -712,16 +654,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -733,15 +668,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
_waitingClients.add(new WaitingClient(accountName, client, key));
|
||||
}
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
sendPacket(new PlayerAuthRequest(accountName, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,19 +445,9 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerLogout pl = new PlayerLogout(account);
|
||||
try
|
||||
{
|
||||
sendPacket(pl);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_accountsInGameServer.remove(account);
|
||||
}
|
||||
|
||||
_accountsInGameServer.remove(account);
|
||||
sendPacket(new PlayerLogout(account));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,15 +468,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendAccessLevel(String account, int level)
|
||||
{
|
||||
final ChangeAccessLevel cal = new ChangeAccessLevel(account, level);
|
||||
try
|
||||
{
|
||||
sendPacket(cal);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangeAccessLevel(account, level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,15 +478,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendClientTracert(String account, String[] address)
|
||||
{
|
||||
final PlayerTracert ptc = new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]);
|
||||
try
|
||||
{
|
||||
sendPacket(ptc);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new PlayerTracert(account, address[0], address[1], address[2], address[3], address[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,15 +489,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendMail(String account, String mailId, String... args)
|
||||
{
|
||||
final SendMail sem = new SendMail(account, mailId, args);
|
||||
try
|
||||
{
|
||||
sendPacket(sem);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new SendMail(account, mailId, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,15 +500,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendTempBan(String account, String ip, long time)
|
||||
{
|
||||
final TempBan tbn = new TempBan(account, ip, time);
|
||||
try
|
||||
{
|
||||
sendPacket(tbn);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new TempBan(account, ip, time));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,53 +569,53 @@ public class LoginServerThread extends Thread
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
try
|
||||
{
|
||||
sendPacket(rec);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ReplyCharacters(account, chars, charToDel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send 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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
catch (Exception e)
|
||||
{
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
LOGGER.severe("LoginServerThread: IOException while sending packet " + packet.getClass().getSimpleName());
|
||||
LOGGER.severe(CommonUtil.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,16 +645,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerStatus(int id, int value)
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(id, value);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(id, value);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,16 +655,9 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendServerType()
|
||||
{
|
||||
final ServerStatus ss = new ServerStatus();
|
||||
ss.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
try
|
||||
{
|
||||
sendPacket(ss);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
final ServerStatus serverStatus = new ServerStatus();
|
||||
serverStatus.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
sendPacket(serverStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,15 +669,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
public void sendChangePassword(String accountName, String charName, String oldpass, String newpass)
|
||||
{
|
||||
final ChangePassword cp = new ChangePassword(accountName, charName, oldpass, newpass);
|
||||
try
|
||||
{
|
||||
sendPacket(cp);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
sendPacket(new ChangePassword(accountName, charName, oldpass, newpass));
|
||||
}
|
||||
|
||||
public int getServerStatus()
|
||||
|
@@ -29,10 +29,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import org.l2jmobius.loginserver.network.GameServerPacketHandler;
|
||||
import org.l2jmobius.loginserver.network.ScrambledKeyPair;
|
||||
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.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
@@ -201,6 +202,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
_connection = con;
|
||||
_connectionIp = con.getInetAddress().getHostAddress();
|
||||
|
||||
try
|
||||
{
|
||||
_in = _connection.getInputStream();
|
||||
@@ -210,6 +212,7 @@ public class GameServerThread extends Thread
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final ScrambledKeyPair pair = LoginController.getInstance().getScrambledRSAKeyPair();
|
||||
_privateKey = (RSAPrivateKey) pair.getPrivateKey();
|
||||
_publicKey = (RSAPublicKey) pair.getPublicKey();
|
||||
@@ -239,18 +242,20 @@ public class GameServerThread extends Thread
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
}
|
||||
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