Login cleanup and organization.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,214 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.commons.crypt;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3.4.1 $ $Date: 2005/03/27 15:30:09 $
|
||||
*/
|
||||
public class NewCrypt
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(NewCrypt.class.getName());
|
||||
BlowfishEngine _crypt;
|
||||
BlowfishEngine _decrypt;
|
||||
|
||||
/**
|
||||
* @param blowfishKey
|
||||
*/
|
||||
public NewCrypt(byte[] blowfishKey)
|
||||
{
|
||||
_crypt = new BlowfishEngine();
|
||||
_crypt.init(true, blowfishKey);
|
||||
_decrypt = new BlowfishEngine();
|
||||
_decrypt.init(false, blowfishKey);
|
||||
}
|
||||
|
||||
public NewCrypt(String key)
|
||||
{
|
||||
this(key.getBytes());
|
||||
}
|
||||
|
||||
public static boolean verifyChecksum(byte[] raw)
|
||||
{
|
||||
return verifyChecksum(raw, 0, raw.length);
|
||||
}
|
||||
|
||||
public static boolean verifyChecksum(byte[] raw, int offset, int size)
|
||||
{
|
||||
// check if size is multiple of 4 and if there is more then only the checksum
|
||||
if (((size & 3) != 0) || (size <= 4))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long chksum = 0;
|
||||
final int count = size - 4;
|
||||
long check = -1;
|
||||
int i;
|
||||
|
||||
for (i = offset; i < count; i += 4)
|
||||
{
|
||||
check = raw[i] & 0xff;
|
||||
check |= (raw[i + 1] << 8) & 0xff00;
|
||||
check |= (raw[i + 2] << 0x10) & 0xff0000;
|
||||
check |= (raw[i + 3] << 0x18) & 0xff000000;
|
||||
|
||||
chksum ^= check;
|
||||
}
|
||||
|
||||
check = raw[i] & 0xff;
|
||||
check |= (raw[i + 1] << 8) & 0xff00;
|
||||
check |= (raw[i + 2] << 0x10) & 0xff0000;
|
||||
check |= (raw[i + 3] << 0x18) & 0xff000000;
|
||||
|
||||
return check == chksum;
|
||||
}
|
||||
|
||||
public static void appendChecksum(byte[] raw)
|
||||
{
|
||||
appendChecksum(raw, 0, raw.length);
|
||||
}
|
||||
|
||||
public static void appendChecksum(byte[] raw, int offset, int size)
|
||||
{
|
||||
long chksum = 0;
|
||||
final int count = size - 4;
|
||||
long ecx;
|
||||
int i;
|
||||
|
||||
for (i = offset; i < count; i += 4)
|
||||
{
|
||||
ecx = raw[i] & 0xff;
|
||||
ecx |= (raw[i + 1] << 8) & 0xff00;
|
||||
ecx |= (raw[i + 2] << 0x10) & 0xff0000;
|
||||
ecx |= (raw[i + 3] << 0x18) & 0xff000000;
|
||||
|
||||
chksum ^= ecx;
|
||||
}
|
||||
|
||||
ecx = raw[i] & 0xff;
|
||||
ecx |= (raw[i + 1] << 8) & 0xff00;
|
||||
ecx |= (raw[i + 2] << 0x10) & 0xff0000;
|
||||
ecx |= (raw[i + 3] << 0x18) & 0xff000000;
|
||||
|
||||
raw[i] = (byte) (chksum & 0xff);
|
||||
raw[i + 1] = (byte) ((chksum >> 0x08) & 0xff);
|
||||
raw[i + 2] = (byte) ((chksum >> 0x10) & 0xff);
|
||||
raw[i + 3] = (byte) ((chksum >> 0x18) & 0xff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Packet is first XOR encoded with <code>key</code> Then, the last 4 bytes are overwritten with the the XOR "key". Thus this assume that there is enough room for the key to fit without overwriting data.
|
||||
* @param raw The raw bytes to be encrypted
|
||||
* @param key The 4 bytes (int) XOR key
|
||||
*/
|
||||
public static void encXORPass(byte[] raw, int key)
|
||||
{
|
||||
encXORPass(raw, 0, raw.length, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Packet is first XOR encoded with <code>key</code> Then, the last 4 bytes are overwritten with the the XOR "key". Thus this assume that there is enough room for the key to fit without overwriting data.
|
||||
* @param raw The raw bytes to be encrypted
|
||||
* @param offset The begining of the data to be encrypted
|
||||
* @param size Length of the data to be encrypted
|
||||
* @param key The 4 bytes (int) XOR key
|
||||
*/
|
||||
public static void encXORPass(byte[] raw, int offset, int size, int key)
|
||||
{
|
||||
final int stop = size - 8;
|
||||
int pos = 4 + offset;
|
||||
int edx;
|
||||
int ecx = key; // Initial xor key
|
||||
|
||||
while (pos < stop)
|
||||
{
|
||||
edx = raw[pos] & 0xFF;
|
||||
edx |= (raw[pos + 1] & 0xFF) << 8;
|
||||
edx |= (raw[pos + 2] & 0xFF) << 16;
|
||||
edx |= (raw[pos + 3] & 0xFF) << 24;
|
||||
|
||||
ecx += edx;
|
||||
|
||||
edx ^= ecx;
|
||||
|
||||
raw[pos++] = (byte) (edx & 0xFF);
|
||||
raw[pos++] = (byte) ((edx >> 8) & 0xFF);
|
||||
raw[pos++] = (byte) ((edx >> 16) & 0xFF);
|
||||
raw[pos++] = (byte) ((edx >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
raw[pos++] = (byte) (ecx & 0xFF);
|
||||
raw[pos++] = (byte) ((ecx >> 8) & 0xFF);
|
||||
raw[pos++] = (byte) ((ecx >> 16) & 0xFF);
|
||||
raw[pos++] = (byte) ((ecx >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
public byte[] decrypt(byte[] raw) throws IOException
|
||||
{
|
||||
final byte[] result = new byte[raw.length];
|
||||
final int count = raw.length / 8;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_decrypt.processBlock(raw, i * 8, result, i * 8);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void decrypt(byte[] raw, int offset, int size) throws IOException
|
||||
{
|
||||
final byte[] result = new byte[size];
|
||||
final int count = size / 8;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_decrypt.processBlock(raw, offset + (i * 8), result, i * 8);
|
||||
}
|
||||
// TODO can the crypt and decrypt go direct to the array
|
||||
System.arraycopy(result, 0, raw, offset, size);
|
||||
}
|
||||
|
||||
public byte[] crypt(byte[] raw) throws IOException
|
||||
{
|
||||
final int count = raw.length / 8;
|
||||
final byte[] result = new byte[raw.length];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_crypt.processBlock(raw, i * 8, result, i * 8);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void crypt(byte[] raw, int offset, int size) throws IOException
|
||||
{
|
||||
final int count = size / 8;
|
||||
final byte[] result = new byte[size];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_crypt.processBlock(raw, offset + (i * 8), result, i * 8);
|
||||
}
|
||||
// TODO can the crypt and decrypt go direct to the array
|
||||
System.arraycopy(result, 0, raw, offset, size);
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.commons.crypt;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
public class ScrambledKeyPair
|
||||
{
|
||||
public KeyPair _pair;
|
||||
public byte[] _scrambledModulus;
|
||||
|
||||
public ScrambledKeyPair(KeyPair pPair)
|
||||
{
|
||||
_pair = pPair;
|
||||
_scrambledModulus = scrambleModulus(((RSAPublicKey) _pair.getPublic()).getModulus());
|
||||
}
|
||||
|
||||
private byte[] scrambleModulus(BigInteger modulus)
|
||||
{
|
||||
byte[] scrambledMod = modulus.toByteArray();
|
||||
|
||||
if ((scrambledMod.length == 0x81) && (scrambledMod[0] == 0x00))
|
||||
{
|
||||
final byte[] temp = new byte[0x80];
|
||||
System.arraycopy(scrambledMod, 1, temp, 0, 0x80);
|
||||
scrambledMod = temp;
|
||||
}
|
||||
|
||||
// step 1 : 0x4d-0x50 <-> 0x00-0x04
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
final byte temp = scrambledMod[0x00 + i];
|
||||
scrambledMod[0x00 + i] = scrambledMod[0x4d + i];
|
||||
scrambledMod[0x4d + i] = temp;
|
||||
}
|
||||
|
||||
// step 2 : xor first 0x40 bytes with last 0x40 bytes
|
||||
for (int i = 0; i < 0x40; i++)
|
||||
{
|
||||
scrambledMod[i] = (byte) (scrambledMod[i] ^ scrambledMod[0x40 + i]);
|
||||
}
|
||||
|
||||
// step 3 : xor bytes 0x0d-0x10 with bytes 0x34-0x38
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
scrambledMod[0x0d + i] = (byte) (scrambledMod[0x0d + i] ^ scrambledMod[0x34 + i]);
|
||||
}
|
||||
|
||||
// step 4 : xor last 0x40 bytes with first 0x40 bytes
|
||||
for (int i = 0; i < 0x40; i++)
|
||||
{
|
||||
scrambledMod[0x40 + i] = (byte) (scrambledMod[0x40 + i] ^ scrambledMod[i]);
|
||||
}
|
||||
|
||||
return scrambledMod;
|
||||
}
|
||||
}
|
@@ -16,35 +16,23 @@
|
||||
*/
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:12 $
|
||||
*/
|
||||
public abstract class BaseRecievePacket implements Runnable
|
||||
public abstract class BaseRecievePacket
|
||||
{
|
||||
private final LoginClient _client;
|
||||
private static final Logger LOGGER = Logger.getLogger(BaseRecievePacket.class.getName());
|
||||
|
||||
private final byte[] _decrypt;
|
||||
private int _off;
|
||||
|
||||
public BaseRecievePacket(byte[] decrypt, LoginClient client)
|
||||
public BaseRecievePacket(byte[] decrypt)
|
||||
{
|
||||
_decrypt = decrypt;
|
||||
_off = 1; // skip packet type id
|
||||
_client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
public LoginClient getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
public byte[] getByteBuffer()
|
||||
{
|
||||
return _decrypt;
|
||||
}
|
||||
|
||||
public int readD()
|
||||
@@ -58,27 +46,24 @@ public abstract class BaseRecievePacket implements Runnable
|
||||
|
||||
public int readC()
|
||||
{
|
||||
final int result = _decrypt[_off++] & 0xff;
|
||||
return result;
|
||||
return _decrypt[_off++] & 0xff;
|
||||
}
|
||||
|
||||
public int readH()
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
return result;
|
||||
return (_decrypt[_off++] & 0xff) | ((_decrypt[_off++] << 8) & 0xff00);
|
||||
}
|
||||
|
||||
public double readF()
|
||||
{
|
||||
long result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
result |= (_decrypt[_off++] << 0x10) & 0xff0000;
|
||||
result |= (_decrypt[_off++] << 0x18) & 0xff000000;
|
||||
result |= (_decrypt[_off++] << 0x20) & 0xff00000000L;
|
||||
result |= (_decrypt[_off++] << 0x28) & 0xff0000000000L;
|
||||
result |= (_decrypt[_off++] << 0x30) & 0xff000000000000L;
|
||||
result |= (_decrypt[_off++] << 0x38) & 0xff00000000000000L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 8L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 16L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 24L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 32L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 40L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 48L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 56L;
|
||||
return Double.longBitsToDouble(result);
|
||||
}
|
||||
|
||||
@@ -87,13 +72,13 @@ public abstract class BaseRecievePacket implements Runnable
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
result = new String(_decrypt, _off, _decrypt.length - _off, "UTF-16LE");
|
||||
result = new String(_decrypt, _off, _decrypt.length - _off, StandardCharsets.UTF_16LE);
|
||||
result = result.substring(0, result.indexOf(0x00));
|
||||
_off += (result.length() * 2) + 2;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -101,11 +86,21 @@ public abstract class BaseRecievePacket implements Runnable
|
||||
public byte[] readB(int length)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
result[i] = _decrypt[_off + i];
|
||||
}
|
||||
System.arraycopy(_decrypt, _off, result, 0, length);
|
||||
_off += length;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public long readQ()
|
||||
{
|
||||
long result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 8L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 16L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 24L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 32L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 40L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 48L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 56L;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -16,79 +16,122 @@
|
||||
*/
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:12 $
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:11 $
|
||||
*/
|
||||
public abstract class BaseSendablePacket
|
||||
{
|
||||
private final byte[] _decrypt;
|
||||
private int _off;
|
||||
private static final Logger LOGGER = Logger.getLogger(BaseSendablePacket.class.getName());
|
||||
|
||||
public BaseSendablePacket(byte[] decrypt)
|
||||
private final ByteArrayOutputStream _bao;
|
||||
|
||||
protected BaseSendablePacket()
|
||||
{
|
||||
_decrypt = decrypt;
|
||||
_off = 1; // skip packet type id
|
||||
_bao = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public int readD()
|
||||
protected void writeD(int value)
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
result |= (_decrypt[_off++] << 0x10) & 0xff0000;
|
||||
result |= (_decrypt[_off++] << 0x18) & 0xff000000;
|
||||
return result;
|
||||
_bao.write(value & 0xff);
|
||||
_bao.write((value >> 8) & 0xff);
|
||||
_bao.write((value >> 16) & 0xff);
|
||||
_bao.write((value >> 24) & 0xff);
|
||||
}
|
||||
|
||||
public int readC()
|
||||
protected void writeH(int value)
|
||||
{
|
||||
final int result = _decrypt[_off++] & 0xff;
|
||||
return result;
|
||||
_bao.write(value & 0xff);
|
||||
_bao.write((value >> 8) & 0xff);
|
||||
}
|
||||
|
||||
public int readH()
|
||||
protected void writeC(int value)
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
return result;
|
||||
_bao.write(value & 0xff);
|
||||
}
|
||||
|
||||
public double readF()
|
||||
protected void writeF(double org)
|
||||
{
|
||||
long result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
result |= (_decrypt[_off++] << 0x10) & 0xff0000;
|
||||
result |= (_decrypt[_off++] << 0x18) & 0xff000000;
|
||||
result |= (_decrypt[_off++] << 0x20) & 0xff00000000l;
|
||||
result |= (_decrypt[_off++] << 0x28) & 0xff0000000000l;
|
||||
result |= (_decrypt[_off++] << 0x30) & 0xff000000000000l;
|
||||
result |= (_decrypt[_off++] << 0x38) & 0xff00000000000000l;
|
||||
return Double.longBitsToDouble(result);
|
||||
final long value = Double.doubleToRawLongBits(org);
|
||||
_bao.write((int) (value & 0xff));
|
||||
_bao.write((int) ((value >> 8) & 0xff));
|
||||
_bao.write((int) ((value >> 16) & 0xff));
|
||||
_bao.write((int) ((value >> 24) & 0xff));
|
||||
_bao.write((int) ((value >> 32) & 0xff));
|
||||
_bao.write((int) ((value >> 40) & 0xff));
|
||||
_bao.write((int) ((value >> 48) & 0xff));
|
||||
_bao.write((int) ((value >> 56) & 0xff));
|
||||
}
|
||||
|
||||
public String readS()
|
||||
protected void writeS(String text)
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
result = new String(_decrypt, _off, _decrypt.length - _off, "UTF-16LE");
|
||||
result = result.substring(0, result.indexOf(0x00));
|
||||
_off += (result.length() * 2) + 2;
|
||||
if (text != null)
|
||||
{
|
||||
_bao.write(text.getBytes(StandardCharsets.UTF_16LE));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
|
||||
_bao.write(0);
|
||||
_bao.write(0);
|
||||
}
|
||||
|
||||
public final byte[] readB(int length)
|
||||
protected void writeB(byte[] array)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
try
|
||||
{
|
||||
result[i] = _decrypt[_off + i];
|
||||
_bao.write(array);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
_off += length;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQ(long value)
|
||||
{
|
||||
_bao.write((int) (value & 0xff));
|
||||
_bao.write((int) ((value >> 8) & 0xff));
|
||||
_bao.write((int) ((value >> 16) & 0xff));
|
||||
_bao.write((int) ((value >> 24) & 0xff));
|
||||
_bao.write((int) ((value >> 32) & 0xff));
|
||||
_bao.write((int) ((value >> 40) & 0xff));
|
||||
_bao.write((int) ((value >> 48) & 0xff));
|
||||
_bao.write((int) ((value >> 56) & 0xff));
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return _bao.size() + 2;
|
||||
}
|
||||
|
||||
public byte[] getBytes()
|
||||
{
|
||||
// if (this instanceof Init)
|
||||
// writeD(0x00); // reserve for XOR initial key
|
||||
|
||||
writeD(0x00); // reserve for checksum
|
||||
|
||||
final int padding = _bao.size() % 8;
|
||||
if (padding != 0)
|
||||
{
|
||||
for (int i = padding; i < 8; i++)
|
||||
{
|
||||
writeC(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
return _bao.toByteArray();
|
||||
}
|
||||
|
||||
public abstract byte[] getContent() throws IOException;
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyFactory;
|
||||
@@ -31,13 +32,15 @@ import java.security.spec.RSAPublicKeySpec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.commons.util.crypt.NewCrypt;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.ConnectionState;
|
||||
@@ -45,7 +48,6 @@ import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.AuthRequest;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.BlowFishKey;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ChangeAccessLevel;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.GameServerBasePacket;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.PlayerAuthRequest;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.PlayerInGame;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.PlayerLogout;
|
||||
@@ -63,8 +65,6 @@ public class LoginServerThread extends Thread
|
||||
protected static final Logger LOGGER = Logger.getLogger(LoginServerThread.class.getName());
|
||||
|
||||
/** The LoginServerThread singleton */
|
||||
private static LoginServerThread _instance;
|
||||
|
||||
private static final int REVISION = 0x0102;
|
||||
private final String _hostname;
|
||||
private final int _port;
|
||||
@@ -76,18 +76,17 @@ public class LoginServerThread extends Thread
|
||||
* The BlowFish engine used to encrypt packets<br>
|
||||
* It is first initialized with a unified key:<br>
|
||||
* "_;v.]05-31!|+-%xT!^[$\00"<br>
|
||||
* <br>
|
||||
* and then after handshake, with a new key sent by<br>
|
||||
* loginserver during the handshake.
|
||||
* login server during the handshake. This new key is stored<br>
|
||||
* in blowfishKey
|
||||
*/
|
||||
private NewCrypt _blowfish;
|
||||
private byte[] _hexID;
|
||||
private final boolean _acceptAlternate;
|
||||
private final int _requestID;
|
||||
private int _serverID;
|
||||
private int _requestID;
|
||||
private final boolean _reserveHost;
|
||||
private int _maxPlayer;
|
||||
private final List<WaitingClient> _waitingClients = new CopyOnWriteArrayList<>();
|
||||
private final Set<WaitingClient> _waitingClients = ConcurrentHashMap.newKeySet();
|
||||
private final Map<String, GameClient> _accountsInGameServer = new ConcurrentHashMap<>();
|
||||
private int _status;
|
||||
private String _serverName;
|
||||
@@ -103,25 +102,20 @@ public class LoginServerThread extends Thread
|
||||
_hexID = Config.HEX_ID;
|
||||
if (_hexID == null)
|
||||
{
|
||||
_requestID = Config.REQUEST_ID;
|
||||
_hexID = generateHex(16);
|
||||
}
|
||||
else
|
||||
{
|
||||
_requestID = Config.SERVER_ID;
|
||||
}
|
||||
_acceptAlternate = Config.ACCEPT_ALTERNATE_ID;
|
||||
_requestID = Config.REQUEST_ID;
|
||||
_reserveHost = Config.RESERVE_HOST_ON_LOGIN;
|
||||
_gameExternalHost = Config.EXTERNAL_HOSTNAME;
|
||||
_gameInternalHost = Config.INTERNAL_HOSTNAME;
|
||||
_maxPlayer = Config.MAXIMUM_ONLINE_USERS;
|
||||
}
|
||||
|
||||
public static LoginServerThread getInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new LoginServerThread();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -134,56 +128,48 @@ public class LoginServerThread extends Thread
|
||||
try
|
||||
{
|
||||
// Connection
|
||||
LOGGER.info("Connecting to login on " + _hostname + ":" + _port);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Connecting to login on " + _hostname + ":" + _port);
|
||||
_loginSocket = new Socket(_hostname, _port);
|
||||
final InputStream in = _loginSocket.getInputStream();
|
||||
_out = new BufferedOutputStream(_loginSocket.getOutputStream());
|
||||
|
||||
// init Blowfish
|
||||
final byte[] blowfishKey = generateHex(40);
|
||||
// Protect the new blowfish key what cannot begin with zero
|
||||
if (blowfishKey[0] == 0)
|
||||
{
|
||||
blowfishKey[0] = (byte) Rnd.get(32, 64);
|
||||
}
|
||||
_blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
|
||||
while (!isInterrupted())
|
||||
{
|
||||
lengthLo = in.read();
|
||||
lengthHi = in.read();
|
||||
length = (lengthHi * 256) + lengthLo;
|
||||
|
||||
if (lengthHi < 0)
|
||||
{
|
||||
LOGGER.finer("LoginServerThread: Login terminated the connection.");
|
||||
LOGGER.finer(getClass().getSimpleName() + ": Login terminated the connection.");
|
||||
break;
|
||||
}
|
||||
|
||||
final byte[] incoming = new byte[length - 2];
|
||||
|
||||
int receivedBytes = 0;
|
||||
int newBytes = 0;
|
||||
int left = length - 2;
|
||||
while ((newBytes != -1) && (receivedBytes < (length - 2)))
|
||||
{
|
||||
newBytes = in.read(incoming, receivedBytes, left);
|
||||
receivedBytes = receivedBytes + newBytes;
|
||||
receivedBytes += newBytes;
|
||||
left -= newBytes;
|
||||
}
|
||||
|
||||
if (receivedBytes != (length - 2))
|
||||
{
|
||||
LOGGER.warning("Incomplete Packet is sent to the server, closing connection.(LS)");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Incomplete Packet is sent to the server, closing connection.(LS)");
|
||||
break;
|
||||
}
|
||||
|
||||
// decrypt if we have a key
|
||||
_blowfish.decrypt(incoming, 0, incoming.length);
|
||||
checksumOk = NewCrypt.verifyChecksum(incoming);
|
||||
|
||||
if (!checksumOk)
|
||||
{
|
||||
LOGGER.warning("Incorrect packet checksum, ignoring packet (LS)");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Incorrect packet checksum, ignoring packet (LS)");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -203,35 +189,37 @@ public class LoginServerThread extends Thread
|
||||
|
||||
try
|
||||
{
|
||||
publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(init.getRSAKey()), RSAKeyGenParameterSpec.F4));
|
||||
final KeyFactory kfac = KeyFactory.getInstance("RSA");
|
||||
final BigInteger modulus = new BigInteger(init.getRSAKey());
|
||||
final RSAPublicKeySpec kspec1 = new RSAPublicKeySpec(modulus, RSAKeyGenParameterSpec.F4);
|
||||
publicKey = (RSAPublicKey) kfac.generatePublic(kspec1);
|
||||
}
|
||||
catch (GeneralSecurityException e)
|
||||
{
|
||||
LOGGER.warning("Trouble while init the public key send by login");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Trouble while init the public key send by login");
|
||||
break;
|
||||
}
|
||||
// send the blowfish key through the rsa encryption
|
||||
sendPacket(new BlowFishKey(blowfishKey, publicKey));
|
||||
// now, only accept packet with the new encryption
|
||||
_blowfish = new NewCrypt(blowfishKey);
|
||||
final AuthRequest ar = new AuthRequest(_requestID, _acceptAlternate, _hexID, _gameExternalHost, _gameInternalHost, _gamePort, _reserveHost, _maxPlayer);
|
||||
sendPacket(ar);
|
||||
sendPacket(new AuthRequest(_requestID, _acceptAlternate, _hexID, _gameExternalHost, _gameInternalHost, _gamePort, _reserveHost, _maxPlayer));
|
||||
break;
|
||||
}
|
||||
case 0x01:
|
||||
{
|
||||
final LoginServerFail lsf = new LoginServerFail(incoming);
|
||||
LOGGER.info("Damn! Registration Failed: " + lsf.getReasonString());
|
||||
LOGGER.info(getClass().getSimpleName() + ": Damn! Registration Failed: " + lsf.getReasonString());
|
||||
// login will close the connection here
|
||||
break;
|
||||
}
|
||||
case 0x02:
|
||||
{
|
||||
final AuthResponse aresp = new AuthResponse(incoming);
|
||||
_serverID = aresp.getServerId();
|
||||
final int serverID = aresp.getServerId();
|
||||
_serverName = aresp.getServerName();
|
||||
Config.saveHexid(_serverID, hexToString(_hexID));
|
||||
LOGGER.info("Registered on login as Server " + _serverID + " : " + _serverName);
|
||||
Config.saveHexid(serverID, hexToString(_hexID));
|
||||
LOGGER.info(getClass().getSimpleName() + ": Registered on login as Server " + serverID + ": " + _serverName);
|
||||
final ServerStatus st = new ServerStatus();
|
||||
if (Config.SERVER_LIST_BRACKET)
|
||||
{
|
||||
@@ -283,11 +271,14 @@ public class LoginServerThread extends Thread
|
||||
final PlayerAuthResponse par = new PlayerAuthResponse(incoming);
|
||||
final String account = par.getAccount();
|
||||
WaitingClient wcToRemove = null;
|
||||
for (WaitingClient wc : _waitingClients)
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
if (wc.account.equals(account))
|
||||
for (WaitingClient wc : _waitingClients)
|
||||
{
|
||||
wcToRemove = wc;
|
||||
if (wc.account.equals(account))
|
||||
{
|
||||
wcToRemove = wc;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wcToRemove != null)
|
||||
@@ -304,7 +295,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warning("Session key is not correct. Closing connection for account " + wcToRemove.account + ".");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Session key is not correct. Closing connection for account " + wcToRemove.account);
|
||||
wcToRemove.gameClient.sendPacket(new AuthLoginFail(AuthLoginFail.SYSTEM_ERROR_LOGIN_LATER));
|
||||
wcToRemove.gameClient.close(new AuthLoginFail(AuthLoginFail.SYSTEM_ERROR_LOGIN_LATER));
|
||||
_accountsInGameServer.remove(wcToRemove.account);
|
||||
@@ -324,22 +315,29 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
LOGGER.info("Disconnected from Login, Trying to reconnect:");
|
||||
LOGGER.info(e.toString());
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ", e);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": LoginServer not avaible, trying to reconnect...");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.info("Disconnected from Login, Trying to reconnect:");
|
||||
LOGGER.info(e.toString());
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Disconnected from Login, Trying to reconnect: ", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
_loginSocket.close();
|
||||
if (isInterrupted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,17 +345,26 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
Thread.sleep(5000); // 5 seconds tempo.
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
return;
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the waiting client and send request.
|
||||
* @param acc the account
|
||||
* @param client the game client
|
||||
* @param key the session key
|
||||
*/
|
||||
public void addWaitingClientAndSendRequest(String acc, GameClient client, SessionKey key)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(acc, client, key);
|
||||
_waitingClients.add(wc);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
}
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(acc, key);
|
||||
try
|
||||
{
|
||||
@@ -365,26 +372,37 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning("Error while sending player auth request.");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the waiting client.
|
||||
* @param client the client
|
||||
*/
|
||||
public void removeWaitingClient(GameClient client)
|
||||
{
|
||||
WaitingClient toRemove = null;
|
||||
for (WaitingClient c : _waitingClients)
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
if (c.gameClient == client)
|
||||
for (WaitingClient c : _waitingClients)
|
||||
{
|
||||
toRemove = c;
|
||||
if (c.gameClient == client)
|
||||
{
|
||||
toRemove = c;
|
||||
}
|
||||
}
|
||||
if (toRemove != null)
|
||||
{
|
||||
_waitingClients.remove(toRemove);
|
||||
}
|
||||
}
|
||||
if (toRemove != null)
|
||||
{
|
||||
_waitingClients.remove(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send logout for the given account.
|
||||
* @param account the account
|
||||
*/
|
||||
public void sendLogout(String account)
|
||||
{
|
||||
if (account == null)
|
||||
@@ -398,7 +416,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning("Error while sending logout packet to login.");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -452,20 +470,40 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a random sequence of bytes returned as byte array
|
||||
* @param size number of random bytes to generate
|
||||
* @return byte array with sequence of random bytes
|
||||
*/
|
||||
public static byte[] generateHex(int size)
|
||||
{
|
||||
final byte[] array = new byte[size];
|
||||
Rnd.nextBytes(array);
|
||||
|
||||
// Don't allow 0s inside the array!
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
while (array[i] == 0)
|
||||
{
|
||||
array[i] = (byte) Rnd.get(Byte.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sl
|
||||
* @throws IOException
|
||||
* Send packet.
|
||||
* @param sl the sendable packet
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void sendPacket(GameServerBasePacket sl) throws IOException
|
||||
private void sendPacket(BaseSendablePacket sl) throws IOException
|
||||
{
|
||||
byte[] data = sl.getContent();
|
||||
if (_blowfish == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final byte[] data = sl.getContent();
|
||||
NewCrypt.appendChecksum(data);
|
||||
_blowfish.crypt(data, 0, data.length);
|
||||
|
||||
@@ -513,6 +551,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,13 +646,6 @@ public class LoginServerThread extends Thread
|
||||
public int loginOkID1;
|
||||
public int loginOkID2;
|
||||
|
||||
/**
|
||||
* Instantiates a new session key.
|
||||
* @param loginOK1 the login o k1
|
||||
* @param loginOK2 the login o k2
|
||||
* @param playOK1 the play o k1
|
||||
* @param playOK2 the play o k2
|
||||
*/
|
||||
public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
|
||||
{
|
||||
playOkID1 = playOK1;
|
||||
@@ -629,7 +661,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
}
|
||||
|
||||
private static class WaitingClient
|
||||
private class WaitingClient
|
||||
{
|
||||
public String account;
|
||||
public GameClient gameClient;
|
||||
@@ -648,4 +680,18 @@ public class LoginServerThread extends Thread
|
||||
session = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of LoginServerThread.
|
||||
* @return single instance of LoginServerThread
|
||||
*/
|
||||
public static LoginServerThread getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final LoginServerThread INSTANCE = new LoginServerThread();
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
public class AuthRequest extends GameServerBasePacket
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
|
||||
public class AuthRequest extends BaseSendablePacket
|
||||
{
|
||||
/**
|
||||
* Format: cccSddb c desired ID c accept alternative ID c reserve Host s ExternalHostName s InetranlHostName d max players d hexid size b hexid
|
||||
|
@@ -16,16 +16,18 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class BlowFishKey extends GameServerBasePacket
|
||||
public class BlowFishKey extends BaseSendablePacket
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(BlowFishKey.class.getName());
|
||||
|
||||
@@ -44,9 +46,9 @@ public class BlowFishKey extends GameServerBasePacket
|
||||
writeD(encrypted.length);
|
||||
writeB(encrypted);
|
||||
}
|
||||
catch (GeneralSecurityException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Error While encrypting blowfish key for transmision (Crypt error) " + e);
|
||||
LOGGER.log(Level.SEVERE, "Error While encrypting blowfish key for transmision (Crypt error): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ChangeAccessLevel extends GameServerBasePacket
|
||||
public class ChangeAccessLevel extends BaseSendablePacket
|
||||
{
|
||||
public ChangeAccessLevel(String player, int access)
|
||||
{
|
||||
@@ -28,10 +30,6 @@ public class ChangeAccessLevel extends GameServerBasePacket
|
||||
writeS(player);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.gameserver.gameserverpackets.GameServerBasePacket#getContent()
|
||||
*/
|
||||
@Override
|
||||
public byte[] getContent()
|
||||
{
|
||||
|
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public abstract class GameServerBasePacket
|
||||
{
|
||||
private final ByteArrayOutputStream _bao;
|
||||
|
||||
protected GameServerBasePacket()
|
||||
{
|
||||
_bao = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
protected void writeD(int value)
|
||||
{
|
||||
_bao.write(value & 0xff);
|
||||
_bao.write((value >> 8) & 0xff);
|
||||
_bao.write((value >> 16) & 0xff);
|
||||
_bao.write((value >> 24) & 0xff);
|
||||
}
|
||||
|
||||
protected void writeH(int value)
|
||||
{
|
||||
_bao.write(value & 0xff);
|
||||
_bao.write((value >> 8) & 0xff);
|
||||
}
|
||||
|
||||
protected void writeC(int value)
|
||||
{
|
||||
_bao.write(value & 0xff);
|
||||
}
|
||||
|
||||
protected void writeF(double org)
|
||||
{
|
||||
final long value = Double.doubleToRawLongBits(org);
|
||||
_bao.write((int) (value & 0xff));
|
||||
_bao.write((int) ((value >> 8) & 0xff));
|
||||
_bao.write((int) ((value >> 16) & 0xff));
|
||||
_bao.write((int) ((value >> 24) & 0xff));
|
||||
_bao.write((int) ((value >> 32) & 0xff));
|
||||
_bao.write((int) ((value >> 40) & 0xff));
|
||||
_bao.write((int) ((value >> 48) & 0xff));
|
||||
_bao.write((int) ((value >> 56) & 0xff));
|
||||
}
|
||||
|
||||
protected void writeS(String text)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
_bao.write(text.getBytes(StandardCharsets.UTF_16LE));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_bao.write(0);
|
||||
_bao.write(0);
|
||||
}
|
||||
|
||||
protected void writeB(byte[] array)
|
||||
{
|
||||
try
|
||||
{
|
||||
_bao.write(array);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return _bao.size() + 2;
|
||||
}
|
||||
|
||||
public byte[] getBytes()
|
||||
{
|
||||
writeD(0x00); // reserve for checksum
|
||||
|
||||
final int padding = _bao.size() % 8;
|
||||
if (padding != 0)
|
||||
{
|
||||
for (int i = padding; i < 8; i++)
|
||||
{
|
||||
writeC(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
return _bao.toByteArray();
|
||||
}
|
||||
|
||||
public abstract byte[] getContent() throws IOException;
|
||||
}
|
@@ -16,12 +16,13 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.gameserver.LoginServerThread.SessionKey;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerAuthRequest extends GameServerBasePacket
|
||||
public class PlayerAuthRequest extends BaseSendablePacket
|
||||
{
|
||||
public PlayerAuthRequest(String account, SessionKey key)
|
||||
{
|
||||
@@ -33,10 +34,6 @@ public class PlayerAuthRequest extends GameServerBasePacket
|
||||
writeD(key.loginOkID2);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.gameserver.gameserverpackets.GameServerBasePacket#getContent()
|
||||
*/
|
||||
@Override
|
||||
public byte[] getContent()
|
||||
{
|
||||
|
@@ -18,10 +18,12 @@ package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerInGame extends GameServerBasePacket
|
||||
public class PlayerInGame extends BaseSendablePacket
|
||||
{
|
||||
public PlayerInGame(String player)
|
||||
{
|
||||
@@ -40,10 +42,6 @@ public class PlayerInGame extends GameServerBasePacket
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.gameserver.gameserverpackets.GameServerBasePacket#getContent()
|
||||
*/
|
||||
@Override
|
||||
public byte[] getContent()
|
||||
{
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerLogout extends GameServerBasePacket
|
||||
public class PlayerLogout extends BaseSendablePacket
|
||||
{
|
||||
public PlayerLogout(String player)
|
||||
{
|
||||
@@ -27,10 +29,6 @@ public class PlayerLogout extends GameServerBasePacket
|
||||
writeS(player);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.gameserver.gameserverpackets.GameServerBasePacket#getContent()
|
||||
*/
|
||||
@Override
|
||||
public byte[] getContent()
|
||||
{
|
||||
|
@@ -19,10 +19,12 @@ package org.l2jmobius.gameserver.network.loginserverpackets.game;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ServerStatus extends GameServerBasePacket
|
||||
public class ServerStatus extends BaseSendablePacket
|
||||
{
|
||||
private final List<Attribute> _attributes;
|
||||
|
||||
@@ -42,6 +44,7 @@ public class ServerStatus extends GameServerBasePacket
|
||||
public static final int MAX_PLAYERS = 0x04;
|
||||
public static final int TEST_SERVER = 0x05;
|
||||
|
||||
// Server Status
|
||||
public static final int STATUS_AUTO = 0x00;
|
||||
public static final int STATUS_GOOD = 0x01;
|
||||
public static final int STATUS_NORMAL = 0x02;
|
||||
@@ -52,7 +55,7 @@ public class ServerStatus extends GameServerBasePacket
|
||||
public static final int ON = 0x01;
|
||||
public static final int OFF = 0x00;
|
||||
|
||||
class Attribute
|
||||
static class Attribute
|
||||
{
|
||||
public int id;
|
||||
public int value;
|
||||
@@ -74,18 +77,13 @@ public class ServerStatus extends GameServerBasePacket
|
||||
_attributes.add(new Attribute(id, value));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.gameserver.gameserverpackets.GameServerBasePacket#getContent()
|
||||
*/
|
||||
@Override
|
||||
public byte[] getContent()
|
||||
{
|
||||
writeC(0x06);
|
||||
writeD(_attributes.size());
|
||||
for (int i = 0; i < _attributes.size(); i++)
|
||||
for (Attribute temp : _attributes)
|
||||
{
|
||||
final Attribute temp = _attributes.get(i);
|
||||
writeD(temp.id);
|
||||
writeD(temp.value);
|
||||
}
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.login;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class AuthResponse extends LoginServerBasePacket
|
||||
public class AuthResponse extends BaseRecievePacket
|
||||
{
|
||||
private final int _serverId;
|
||||
private final String _serverName;
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.login;
|
||||
|
||||
public class InitLS extends LoginServerBasePacket
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
|
||||
public class InitLS extends BaseRecievePacket
|
||||
{
|
||||
private final int _rev;
|
||||
private final byte[] _key;
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.login;
|
||||
|
||||
public class KickPlayer extends LoginServerBasePacket
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
|
||||
public class KickPlayer extends BaseRecievePacket
|
||||
{
|
||||
private final String _account;
|
||||
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.login;
|
||||
|
||||
public class LoginServerFail extends LoginServerBasePacket
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
|
||||
public class LoginServerFail extends BaseRecievePacket
|
||||
{
|
||||
private static final String[] REASONS =
|
||||
{
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.login;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerAuthResponse extends LoginServerBasePacket
|
||||
public class PlayerAuthResponse extends BaseRecievePacket
|
||||
{
|
||||
private final String _account;
|
||||
private final boolean _authed;
|
||||
|
@@ -31,7 +31,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.util.crypt.NewCrypt;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.BlowFishKey;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.ChangeAccessLevel;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.GameServerAuth;
|
||||
@@ -44,7 +45,6 @@ import org.l2jmobius.loginserver.network.loginserverpackets.InitLS;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.KickPlayer;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.LoginServerFail;
|
||||
import org.l2jmobius.loginserver.network.loginserverpackets.PlayerAuthResponse;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
@@ -400,7 +400,7 @@ public class GameServerThread extends Thread
|
||||
* @param sl
|
||||
* @throws IOException
|
||||
*/
|
||||
private void sendPacket(ServerBasePacket sl) throws IOException
|
||||
private void sendPacket(AbstractServerPacket sl) throws IOException
|
||||
{
|
||||
byte[] data = sl.getContent();
|
||||
NewCrypt.appendChecksum(data);
|
||||
|
@@ -27,15 +27,14 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.commons.util.crypt.NewCrypt;
|
||||
import org.l2jmobius.loginserver.LoginController.ScrambledKeyPair;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.Init;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.15.2.5.2.5 $ $Date: 2005/04/06 16:13:46 $
|
||||
*/
|
||||
public class LoginClient extends Thread
|
||||
@@ -157,7 +156,7 @@ public class LoginClient extends Thread
|
||||
}
|
||||
|
||||
// Execute client packet.
|
||||
final BaseRecievePacket packet = LoginPacketHandler.handlePacket(decrypt, this);
|
||||
final AbstractClientPacket packet = LoginPacketHandler.handlePacket(decrypt, this);
|
||||
if (packet != null)
|
||||
{
|
||||
LoginServer.getInstance().execute(packet);
|
||||
@@ -196,7 +195,7 @@ public class LoginClient extends Thread
|
||||
/**
|
||||
* @param sl
|
||||
*/
|
||||
public void sendPacket(ServerBasePacket sl)
|
||||
public void sendPacket(AbstractServerPacket sl)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -18,8 +18,8 @@ package org.l2jmobius.loginserver;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.loginserver.LoginClient.LoginClientState;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.network.clientpackets.RequestAuthGG;
|
||||
import org.l2jmobius.loginserver.network.clientpackets.RequestAuthLogin;
|
||||
import org.l2jmobius.loginserver.network.clientpackets.RequestServerList;
|
||||
@@ -33,10 +33,10 @@ public class LoginPacketHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(LoginPacketHandler.class.getName());
|
||||
|
||||
public static BaseRecievePacket handlePacket(byte[] data, LoginClient client)
|
||||
public static AbstractClientPacket handlePacket(byte[] data, LoginClient client)
|
||||
{
|
||||
final int opcode = data[0] & 0xFF;
|
||||
BaseRecievePacket packet = null;
|
||||
AbstractClientPacket packet = null;
|
||||
final LoginClientState state = client.getClientState();
|
||||
|
||||
switch (state)
|
||||
|
@@ -38,7 +38,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseBackup;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.ui.Gui;
|
||||
import org.l2jmobius.telnet.TelnetStatusThread;
|
||||
|
||||
@@ -282,7 +282,7 @@ public class LoginServer extends FloodProtectedListener
|
||||
public long lastConnection;
|
||||
}
|
||||
|
||||
public void execute(BaseRecievePacket packet)
|
||||
public void execute(AbstractClientPacket packet)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -14,20 +14,37 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.loginserverpackets.login;
|
||||
package org.l2jmobius.loginserver.network;
|
||||
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:12 $
|
||||
*/
|
||||
public abstract class LoginServerBasePacket
|
||||
public abstract class AbstractClientPacket implements Runnable
|
||||
{
|
||||
private final LoginClient _client;
|
||||
private final byte[] _decrypt;
|
||||
private int _off;
|
||||
|
||||
public LoginServerBasePacket(byte[] decrypt)
|
||||
public AbstractClientPacket(byte[] decrypt, LoginClient client)
|
||||
{
|
||||
_decrypt = decrypt;
|
||||
_off = 1; // skip packet type id
|
||||
_client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
public LoginClient getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
public byte[] getByteBuffer()
|
||||
{
|
||||
return _decrypt;
|
||||
}
|
||||
|
||||
public int readD()
|
||||
@@ -91,4 +108,4 @@ public abstract class LoginServerBasePacket
|
||||
_off += length;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:12 $
|
||||
*/
|
||||
public abstract class AbstractGameServerPacket
|
||||
{
|
||||
private final byte[] _decrypt;
|
||||
private int _off;
|
||||
|
||||
public AbstractGameServerPacket(byte[] decrypt)
|
||||
{
|
||||
_decrypt = decrypt;
|
||||
_off = 1; // skip packet type id
|
||||
}
|
||||
|
||||
public int readD()
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
result |= (_decrypt[_off++] << 0x10) & 0xff0000;
|
||||
result |= (_decrypt[_off++] << 0x18) & 0xff000000;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int readC()
|
||||
{
|
||||
final int result = _decrypt[_off++] & 0xff;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int readH()
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
return result;
|
||||
}
|
||||
|
||||
public double readF()
|
||||
{
|
||||
long result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
result |= (_decrypt[_off++] << 0x10) & 0xff0000;
|
||||
result |= (_decrypt[_off++] << 0x18) & 0xff000000;
|
||||
result |= (_decrypt[_off++] << 0x20) & 0xff00000000l;
|
||||
result |= (_decrypt[_off++] << 0x28) & 0xff0000000000l;
|
||||
result |= (_decrypt[_off++] << 0x30) & 0xff000000000000l;
|
||||
result |= (_decrypt[_off++] << 0x38) & 0xff00000000000000l;
|
||||
return Double.longBitsToDouble(result);
|
||||
}
|
||||
|
||||
public String readS()
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
result = new String(_decrypt, _off, _decrypt.length - _off, "UTF-16LE");
|
||||
result = result.substring(0, result.indexOf(0x00));
|
||||
_off += (result.length() * 2) + 2;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final byte[] readB(int length)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
result[i] = _decrypt[_off + i];
|
||||
}
|
||||
_off += length;
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
package org.l2jmobius.loginserver.network;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -24,11 +24,11 @@ import java.nio.charset.StandardCharsets;
|
||||
* This class ...
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:11 $
|
||||
*/
|
||||
public abstract class ServerBasePacket
|
||||
public abstract class AbstractServerPacket
|
||||
{
|
||||
ByteArrayOutputStream _bao;
|
||||
|
||||
protected ServerBasePacket()
|
||||
protected AbstractServerPacket()
|
||||
{
|
||||
_bao = new ByteArrayOutputStream();
|
||||
}
|
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
import org.l2jmobius.loginserver.LoginClient.LoginClientState;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.GGAuth;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.LoginFail;
|
||||
|
||||
public class RequestAuthGG extends BaseRecievePacket
|
||||
public class RequestAuthGG extends AbstractClientPacket
|
||||
{
|
||||
private int _sessionId = 0;
|
||||
private final int _data1;
|
||||
|
@@ -23,13 +23,13 @@ import java.util.logging.Logger;
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.loginserver.GameServerTable;
|
||||
import org.l2jmobius.loginserver.GameServerThread;
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
import org.l2jmobius.loginserver.LoginClient.LoginClientState;
|
||||
import org.l2jmobius.loginserver.LoginController;
|
||||
import org.l2jmobius.loginserver.LoginServer;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.AccountKicked;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.LoginFail;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.LoginOk;
|
||||
@@ -37,7 +37,7 @@ import org.l2jmobius.loginserver.network.serverpackets.LoginOk;
|
||||
/**
|
||||
* Format: x 0 (a leading null) x: the rsa encrypted block with the login an password
|
||||
*/
|
||||
public class RequestAuthLogin extends BaseRecievePacket
|
||||
public class RequestAuthLogin extends AbstractClientPacket
|
||||
{
|
||||
private final static Logger LOGGER = Logger.getLogger(RequestAuthLogin.class.getName());
|
||||
|
||||
|
@@ -16,15 +16,15 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.loginserver.GameServerTable;
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.LoginFail;
|
||||
|
||||
/**
|
||||
* Format: ddc d: fist part of session id d: second part of session id c: ? (session ID is sent in LoginOk packet and fixed to 0x55555555 0x44444444)
|
||||
*/
|
||||
public class RequestServerList extends BaseRecievePacket
|
||||
public class RequestServerList extends AbstractClientPacket
|
||||
{
|
||||
private final int _key1;
|
||||
private final int _key2;
|
||||
|
@@ -19,10 +19,10 @@ package org.l2jmobius.loginserver.network.clientpackets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.BaseRecievePacket;
|
||||
import org.l2jmobius.loginserver.GameServerTable;
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
import org.l2jmobius.loginserver.LoginController;
|
||||
import org.l2jmobius.loginserver.network.AbstractClientPacket;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.LoginFail;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.PlayFail;
|
||||
@@ -31,7 +31,7 @@ import org.l2jmobius.loginserver.network.serverpackets.PlayOk;
|
||||
/**
|
||||
* Fromat is ddc d: first part of session id d: second part of session id c: server ID (session ID is sent in LoginOk packet and fixed to 0x55555555 0x44444444)
|
||||
*/
|
||||
public class RequestServerLogin extends BaseRecievePacket
|
||||
public class RequestServerLogin extends AbstractClientPacket
|
||||
{
|
||||
private final static Logger LOGGER = Logger.getLogger(RequestServerLogin.class.getName());
|
||||
|
||||
|
@@ -22,12 +22,12 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class BlowFishKey extends BaseSendablePacket
|
||||
public class BlowFishKey extends AbstractGameServerPacket
|
||||
{
|
||||
byte[] _key;
|
||||
protected static final Logger LOGGER = Logger.getLogger(BlowFishKey.class.getName());
|
||||
|
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ChangeAccessLevel extends BaseSendablePacket
|
||||
public class ChangeAccessLevel extends AbstractGameServerPacket
|
||||
{
|
||||
private final int _level;
|
||||
private final String _account;
|
||||
|
@@ -18,13 +18,13 @@ package org.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* Format: cccddb c desired ID c accept alternative ID c reserve Host s ExternalHostName s InetranlHostName d max players d hexid size b hexid
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class GameServerAuth extends BaseSendablePacket
|
||||
public class GameServerAuth extends AbstractGameServerPacket
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(GameServerAuth.class.getName());
|
||||
private final byte[] _hexId;
|
||||
|
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.SessionKey;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerAuthRequest extends BaseSendablePacket
|
||||
public class PlayerAuthRequest extends AbstractGameServerPacket
|
||||
{
|
||||
private final String _account;
|
||||
private final SessionKey _sessionKey;
|
||||
|
@@ -19,12 +19,12 @@ package org.l2jmobius.loginserver.network.gameserverpackets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerInGame extends BaseSendablePacket
|
||||
public class PlayerInGame extends AbstractGameServerPacket
|
||||
{
|
||||
private final List<String> _accounts;
|
||||
|
||||
|
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerLogout extends BaseSendablePacket
|
||||
public class PlayerLogout extends AbstractGameServerPacket
|
||||
{
|
||||
private final String _account;
|
||||
|
||||
|
@@ -18,13 +18,13 @@ package org.l2jmobius.loginserver.network.gameserverpackets;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.loginserver.GameServerTable;
|
||||
import org.l2jmobius.loginserver.network.AbstractGameServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ServerStatus extends BaseSendablePacket
|
||||
public class ServerStatus extends AbstractGameServerPacket
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(ServerStatus.class.getName());
|
||||
|
||||
|
@@ -17,12 +17,12 @@
|
||||
package org.l2jmobius.loginserver.network.loginserverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.GameServerTable;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class AuthResponse extends ServerBasePacket
|
||||
public class AuthResponse extends AbstractServerPacket
|
||||
{
|
||||
/**
|
||||
* @param serverId
|
||||
|
@@ -17,12 +17,12 @@
|
||||
package org.l2jmobius.loginserver.network.loginserverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.LoginServer;
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class InitLS extends ServerBasePacket
|
||||
public class InitLS extends AbstractServerPacket
|
||||
{
|
||||
// ID 0x00
|
||||
// format
|
||||
|
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.loginserverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class KickPlayer extends ServerBasePacket
|
||||
public class KickPlayer extends AbstractServerPacket
|
||||
{
|
||||
public KickPlayer(String account)
|
||||
{
|
||||
|
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.loginserverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class LoginServerFail extends ServerBasePacket
|
||||
public class LoginServerFail extends AbstractServerPacket
|
||||
{
|
||||
public static final int REASON_IP_BANNED = 1;
|
||||
public static final int REASON_IP_RESERVED = 2;
|
||||
|
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.loginserverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.network.serverpackets.ServerBasePacket;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class PlayerAuthResponse extends ServerBasePacket
|
||||
public class PlayerAuthResponse extends AbstractServerPacket
|
||||
{
|
||||
public PlayerAuthResponse(String account, boolean response)
|
||||
{
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
public class AccountKicked extends ServerBasePacket
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
public class AccountKicked extends AbstractServerPacket
|
||||
{
|
||||
public static int REASON_ILLEGAL_USE = 0x01;
|
||||
public static int REASON_GENERAL_VIOLATION = 0x08;
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* Fromat: d d: response
|
||||
*/
|
||||
public class GGAuth extends ServerBasePacket
|
||||
public class GGAuth extends AbstractServerPacket
|
||||
{
|
||||
public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
|
||||
|
||||
|
@@ -17,11 +17,12 @@
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.LoginClient;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* Format: dd b dddd s d: session id d: protocol revision b: 0x90 bytes : 0x80 bytes for the scrambled RSA public key 0x10 bytes at 0x00 d: unknow d: unknow d: unknow d: unknow s: blowfish key
|
||||
*/
|
||||
public final class Init extends ServerBasePacket
|
||||
public final class Init extends AbstractServerPacket
|
||||
{
|
||||
public Init(LoginClient client)
|
||||
{
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* Fromat: d d: the failure reason
|
||||
*/
|
||||
public class LoginFail extends ServerBasePacket
|
||||
public class LoginFail extends AbstractServerPacket
|
||||
{
|
||||
public static int REASON_SYSTEM_ERROR = 0x01;
|
||||
public static int REASON_PASS_WRONG = 0x02;
|
||||
|
@@ -17,11 +17,12 @@
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.SessionKey;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* Format: dddddddd f: the session key d: ? d: ? d: ? d: ? d: ? d: ?
|
||||
*/
|
||||
public class LoginOk extends ServerBasePacket
|
||||
public class LoginOk extends AbstractServerPacket
|
||||
{
|
||||
public LoginOk(SessionKey sessionKey)
|
||||
{
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:11 $
|
||||
*/
|
||||
public class PlayFail extends ServerBasePacket
|
||||
public class PlayFail extends AbstractServerPacket
|
||||
{
|
||||
public static int REASON_TOO_MANY_PLAYERS = 0x0f; // too many players on server
|
||||
public static int REASON_SYSTEM_ERROR = 0x01; // system error
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.loginserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.loginserver.SessionKey;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -29,7 +30,7 @@ import org.l2jmobius.loginserver.SessionKey;
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class PlayOk extends ServerBasePacket
|
||||
public class PlayOk extends AbstractServerPacket
|
||||
{
|
||||
public PlayOk(SessionKey sessionKey)
|
||||
{
|
||||
|
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.loginserver.GameServerTable.GameServer;
|
||||
import org.l2jmobius.loginserver.network.AbstractServerPacket;
|
||||
import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
|
||||
|
||||
/**
|
||||
@@ -29,7 +30,7 @@ import org.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
|
||||
* server is down d: 2nd bit: clock 3rd bit: wont dsiplay server name 4th bit: test server (used by client?) c: 0 if you dont want to display brackets in front of sever name ] Server will be considered as Good when the number of online players is less than half the maximum. as Normal between half
|
||||
* and 4/5 and Full when there's more than 4/5 of the maximum number of players
|
||||
*/
|
||||
public class ServerList extends ServerBasePacket
|
||||
public class ServerList extends AbstractServerPacket
|
||||
{
|
||||
private final List<ServerData> _servers;
|
||||
|
||||
|
Reference in New Issue
Block a user