Project update.

This commit is contained in:
MobiusDev
2015-12-31 23:53:41 +00:00
parent e0d681a17e
commit ad2bcd79be
4084 changed files with 83696 additions and 86998 deletions

View File

@@ -0,0 +1,159 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network;
import java.util.logging.Logger;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.loginserver.network.gameserverpackets.BlowFishKey;
import com.l2jmobius.loginserver.network.gameserverpackets.ChangeAccessLevel;
import com.l2jmobius.loginserver.network.gameserverpackets.ChangePassword;
import com.l2jmobius.loginserver.network.gameserverpackets.GameServerAuth;
import com.l2jmobius.loginserver.network.gameserverpackets.PlayerAuthRequest;
import com.l2jmobius.loginserver.network.gameserverpackets.PlayerInGame;
import com.l2jmobius.loginserver.network.gameserverpackets.PlayerLogout;
import com.l2jmobius.loginserver.network.gameserverpackets.PlayerTracert;
import com.l2jmobius.loginserver.network.gameserverpackets.ReplyCharacters;
import com.l2jmobius.loginserver.network.gameserverpackets.RequestTempBan;
import com.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
import com.l2jmobius.loginserver.network.loginserverpackets.LoginServerFail;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author mrTJO
*/
public class L2JGameServerPacketHandler
{
protected static Logger _log = Logger.getLogger(L2JGameServerPacketHandler.class.getName());
public static enum GameServerState
{
CONNECTED,
BF_CONNECTED,
AUTHED
}
public static BaseRecievePacket handlePacket(byte[] data, GameServerThread server)
{
BaseRecievePacket msg = null;
final int opcode = data[0] & 0xff;
final GameServerState state = server.getLoginConnectionState();
switch (state)
{
case CONNECTED:
{
switch (opcode)
{
case 0x00:
{
msg = new BlowFishKey(data, server);
break;
}
default:
{
_log.warning("Unknown Opcode (" + Integer.toHexString(opcode).toUpperCase() + ") in state " + state.name() + " from GameServer, closing connection.");
server.forceClose(LoginServerFail.NOT_AUTHED);
break;
}
}
break;
}
case BF_CONNECTED:
{
switch (opcode)
{
case 0x01:
{
msg = new GameServerAuth(data, server);
break;
}
default:
{
_log.warning("Unknown Opcode (" + Integer.toHexString(opcode).toUpperCase() + ") in state " + state.name() + " from GameServer, closing connection.");
server.forceClose(LoginServerFail.NOT_AUTHED);
break;
}
}
break;
}
case AUTHED:
{
switch (opcode)
{
case 0x02:
{
msg = new PlayerInGame(data, server);
break;
}
case 0x03:
{
msg = new PlayerLogout(data, server);
break;
}
case 0x04:
{
msg = new ChangeAccessLevel(data, server);
break;
}
case 0x05:
{
msg = new PlayerAuthRequest(data, server);
break;
}
case 0x06:
{
msg = new ServerStatus(data, server);
break;
}
case 0x07:
{
msg = new PlayerTracert(data);
break;
}
case 0x08:
{
msg = new ReplyCharacters(data, server);
break;
}
case 0x09:
{
// msg = new RequestSendMail(data);
break;
}
case 0x0A:
{
msg = new RequestTempBan(data);
break;
}
case 0x0B:
{
new ChangePassword(data);
break;
}
default:
{
_log.warning("Unknown Opcode (" + Integer.toHexString(opcode).toUpperCase() + ") in state " + state.name() + " from GameServer, closing connection.");
server.forceClose(LoginServerFail.NOT_AUTHED);
break;
}
}
break;
}
}
return msg;
}
}

View File

@@ -0,0 +1,293 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.security.interfaces.RSAPrivateKey;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.mmocore.MMOClient;
import com.l2jmobius.commons.mmocore.MMOConnection;
import com.l2jmobius.commons.mmocore.SendablePacket;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.loginserver.SessionKey;
import com.l2jmobius.loginserver.network.serverpackets.L2LoginServerPacket;
import com.l2jmobius.loginserver.network.serverpackets.LoginFail;
import com.l2jmobius.loginserver.network.serverpackets.LoginFail.LoginFailReason;
import com.l2jmobius.loginserver.network.serverpackets.PlayFail;
import com.l2jmobius.loginserver.network.serverpackets.PlayFail.PlayFailReason;
import com.l2jmobius.util.Rnd;
import com.l2jmobius.util.crypt.LoginCrypt;
import com.l2jmobius.util.crypt.ScrambledKeyPair;
/**
* Represents a client connected into the LoginServer
* @author KenM
*/
public final class L2LoginClient extends MMOClient<MMOConnection<L2LoginClient>>
{
private static final Logger _log = Logger.getLogger(L2LoginClient.class.getName());
public static enum LoginClientState
{
CONNECTED,
AUTHED_GG,
AUTHED_LOGIN
}
private LoginClientState _state;
// Crypt
private final LoginCrypt _loginCrypt;
private final ScrambledKeyPair _scrambledPair;
private final byte[] _blowfishKey;
private String _account;
private int _accessLevel;
private int _lastServer;
private SessionKey _sessionKey;
private final int _sessionId;
private boolean _joinedGS;
private Map<Integer, Integer> _charsOnServers;
private Map<Integer, long[]> _charsToDelete;
private final long _connectionStartTime;
/**
* @param con
*/
public L2LoginClient(MMOConnection<L2LoginClient> con)
{
super(con);
_state = LoginClientState.CONNECTED;
_scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair();
_blowfishKey = LoginController.getInstance().getBlowfishKey();
_sessionId = Rnd.nextInt();
_connectionStartTime = System.currentTimeMillis();
_loginCrypt = new LoginCrypt();
_loginCrypt.setKey(_blowfishKey);
}
@Override
public boolean decrypt(ByteBuffer buf, int size)
{
boolean isChecksumValid = false;
try
{
isChecksumValid = _loginCrypt.decrypt(buf.array(), buf.position(), size);
if (!isChecksumValid)
{
// _log.warning("Wrong checksum from client: " + toString());
// super.getConnection().close((SendablePacket<L2LoginClient>) null);
// return false;
}
return true;
}
catch (IOException e)
{
_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
super.getConnection().close((SendablePacket<L2LoginClient>) null);
return false;
}
}
@Override
public boolean encrypt(ByteBuffer buf, int size)
{
final int offset = buf.position();
try
{
size = _loginCrypt.encrypt(buf.array(), offset, size);
}
catch (IOException e)
{
_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
return false;
}
buf.position(offset + size);
return true;
}
public LoginClientState getState()
{
return _state;
}
public void setState(LoginClientState state)
{
_state = state;
}
public byte[] getBlowfishKey()
{
return _blowfishKey;
}
public byte[] getScrambledModulus()
{
return _scrambledPair._scrambledModulus;
}
public RSAPrivateKey getRSAPrivateKey()
{
return (RSAPrivateKey) _scrambledPair._pair.getPrivate();
}
public String getAccount()
{
return _account;
}
public void setAccount(String account)
{
_account = account;
}
public void setAccessLevel(int accessLevel)
{
_accessLevel = accessLevel;
}
public int getAccessLevel()
{
return _accessLevel;
}
public void setLastServer(int lastServer)
{
_lastServer = lastServer;
}
public int getLastServer()
{
return _lastServer;
}
public int getSessionId()
{
return _sessionId;
}
public boolean hasJoinedGS()
{
return _joinedGS;
}
public void setJoinedGS(boolean val)
{
_joinedGS = val;
}
public void setSessionKey(SessionKey sessionKey)
{
_sessionKey = sessionKey;
}
public SessionKey getSessionKey()
{
return _sessionKey;
}
public long getConnectionStartTime()
{
return _connectionStartTime;
}
public void sendPacket(L2LoginServerPacket lsp)
{
getConnection().sendPacket(lsp);
}
public void close(LoginFailReason reason)
{
getConnection().close(new LoginFail(reason));
}
public void close(PlayFailReason reason)
{
getConnection().close(new PlayFail(reason));
}
public void close(L2LoginServerPacket lsp)
{
getConnection().close(lsp);
}
public void setCharsOnServ(int servId, int chars)
{
if (_charsOnServers == null)
{
_charsOnServers = new HashMap<>();
}
_charsOnServers.put(servId, chars);
}
public Map<Integer, Integer> getCharsOnServ()
{
return _charsOnServers;
}
public void serCharsWaitingDelOnServ(int servId, long[] charsToDel)
{
if (_charsToDelete == null)
{
_charsToDelete = new HashMap<>();
}
_charsToDelete.put(servId, charsToDel);
}
public Map<Integer, long[]> getCharsWaitingDelOnServ()
{
return _charsToDelete;
}
@Override
public void onDisconnection()
{
if (Config.DEBUG)
{
_log.info("DISCONNECTED: " + toString());
}
if (!hasJoinedGS() || ((getConnectionStartTime() + LoginController.LOGIN_TIMEOUT) < System.currentTimeMillis()))
{
LoginController.getInstance().removeAuthedLoginClient(getAccount());
}
}
@Override
public String toString()
{
final InetAddress address = getConnection().getInetAddress();
if (getState() == LoginClientState.AUTHED_LOGIN)
{
return "[" + getAccount() + " (" + (address == null ? "disconnected" : address.getHostAddress()) + ")]";
}
return "[" + (address == null ? "disconnected" : address.getHostAddress()) + "]";
}
@Override
protected void onForcedDisconnection()
{
// Empty
}
}

View File

@@ -0,0 +1,112 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network;
import java.nio.ByteBuffer;
import java.util.logging.Logger;
import com.l2jmobius.commons.mmocore.IPacketHandler;
import com.l2jmobius.commons.mmocore.ReceivablePacket;
import com.l2jmobius.loginserver.network.L2LoginClient.LoginClientState;
import com.l2jmobius.loginserver.network.clientpackets.AuthGameGuard;
import com.l2jmobius.loginserver.network.clientpackets.RequestAuthLogin;
import com.l2jmobius.loginserver.network.clientpackets.RequestServerList;
import com.l2jmobius.loginserver.network.clientpackets.RequestServerLogin;
/**
* Handler for packets received by Login Server
* @author KenM
*/
public final class L2LoginPacketHandler implements IPacketHandler<L2LoginClient>
{
protected static final Logger _log = Logger.getLogger(L2LoginPacketHandler.class.getName());
@Override
public ReceivablePacket<L2LoginClient> handlePacket(ByteBuffer buf, L2LoginClient client)
{
final int opcode = buf.get() & 0xFF;
ReceivablePacket<L2LoginClient> packet = null;
final LoginClientState state = client.getState();
switch (state)
{
case CONNECTED:
{
switch (opcode)
{
case 0x07:
{
packet = new AuthGameGuard();
break;
}
default:
{
debugOpcode(opcode, state);
break;
}
}
break;
}
case AUTHED_GG:
{
switch (opcode)
{
case 0x00:
{
packet = new RequestAuthLogin();
break;
}
default:
{
debugOpcode(opcode, state);
break;
}
}
break;
}
case AUTHED_LOGIN:
{
switch (opcode)
{
case 0x02:
{
packet = new RequestServerLogin();
break;
}
case 0x05:
{
packet = new RequestServerList();
break;
}
default:
{
debugOpcode(opcode, state);
break;
}
}
break;
}
}
return packet;
}
private void debugOpcode(int opcode, LoginClientState state)
{
_log.info("Unknown Opcode: " + opcode + " for state: " + state.name());
}
}

View File

@@ -0,0 +1,88 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.clientpackets;
import com.l2jmobius.loginserver.network.L2LoginClient.LoginClientState;
import com.l2jmobius.loginserver.network.serverpackets.GGAuth;
import com.l2jmobius.loginserver.network.serverpackets.LoginFail.LoginFailReason;
/**
* Format: ddddd
* @author -Wooden-
*/
public class AuthGameGuard extends L2LoginClientPacket
{
private int _sessionId;
private int _data1;
private int _data2;
private int _data3;
private int _data4;
public int getSessionId()
{
return _sessionId;
}
public int getData1()
{
return _data1;
}
public int getData2()
{
return _data2;
}
public int getData3()
{
return _data3;
}
public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
getClient().setState(LoginClientState.AUTHED_GG);
getClient().sendPacket(new GGAuth(getClient().getSessionId()));
}
else
{
getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
}
}
}

View File

@@ -0,0 +1,47 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.mmocore.ReceivablePacket;
import com.l2jmobius.loginserver.network.L2LoginClient;
/**
* @author KenM
*/
public abstract class L2LoginClientPacket extends ReceivablePacket<L2LoginClient>
{
private static Logger _log = Logger.getLogger(L2LoginClientPacket.class.getName());
@Override
protected final boolean read()
{
try
{
return readImpl();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "ERROR READING: " + this.getClass().getSimpleName() + ": " + e.getMessage(), e);
return false;
}
}
protected abstract boolean readImpl();
}

View File

@@ -0,0 +1,211 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.clientpackets;
import java.net.InetAddress;
import java.security.GeneralSecurityException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Cipher;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.loginserver.LoginController.AuthLoginResult;
import com.l2jmobius.loginserver.model.data.AccountInfo;
import com.l2jmobius.loginserver.network.L2LoginClient;
import com.l2jmobius.loginserver.network.L2LoginClient.LoginClientState;
import com.l2jmobius.loginserver.network.serverpackets.AccountKicked;
import com.l2jmobius.loginserver.network.serverpackets.AccountKicked.AccountKickedReason;
import com.l2jmobius.loginserver.network.serverpackets.LoginFail.LoginFailReason;
import com.l2jmobius.loginserver.network.serverpackets.LoginOk;
import com.l2jmobius.loginserver.network.serverpackets.ServerList;
/**
* <pre>
* Format: x 0 (a leading null) x: the rsa encrypted block with the login an password.
*
* <pre>
*/
public class RequestAuthLogin extends L2LoginClientPacket
{
private static Logger _log = Logger.getLogger(RequestAuthLogin.class.getName());
private final byte[] _raw1 = new byte[128];
private final byte[] _raw2 = new byte[128];
private boolean _newAuthMethod = false;
private String _user;
private String _password;
private int _ncotp;
/**
* @return
*/
public String getPassword()
{
return _password;
}
/**
* @return
*/
public String getUser()
{
return _user;
}
public int getOneTimePassword()
{
return _ncotp;
}
@Override
public boolean readImpl()
{
if (super._buf.remaining() >= 256)
{
_newAuthMethod = true;
readB(_raw1);
readB(_raw2);
return true;
}
else if (super._buf.remaining() >= 128)
{
readB(_raw1);
return true;
}
return false;
}
@Override
public void run()
{
byte[] decUser = null;
byte[] decPass = null;
final L2LoginClient client = getClient();
try
{
final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey());
decUser = rsaCipher.doFinal(_raw1, 0x00, 0x80);
if (_newAuthMethod)
{
decPass = rsaCipher.doFinal(_raw2, 0x00, 0x80);
}
}
catch (GeneralSecurityException e)
{
_log.log(Level.INFO, "", e);
return;
}
try
{
if (_newAuthMethod)
{
_user = new String(decUser, 0x4E, 0xE).trim().toLowerCase();
_password = new String(decPass, 0x5C, 0x10).trim();
}
else
{
_user = new String(decUser, 0x5E, 0xE).trim().toLowerCase();
_password = new String(decUser, 0x6C, 0x10).trim();
}
_ncotp = decUser[0x7c];
_ncotp |= decUser[0x7d] << 8;
_ncotp |= decUser[0x7e] << 16;
_ncotp |= decUser[0x7f] << 24;
}
catch (Exception e)
{
_log.log(Level.WARNING, "", e);
return;
}
final InetAddress clientAddr = getClient().getConnection().getInetAddress();
final LoginController lc = LoginController.getInstance();
final AccountInfo info = lc.retriveAccountInfo(clientAddr, _user, _password);
if (info == null)
{
// user or pass wrong
client.close(LoginFailReason.REASON_USER_OR_PASS_WRONG);
return;
}
final AuthLoginResult result = lc.tryCheckinAccount(client, clientAddr, info);
switch (result)
{
case AUTH_SUCCESS:
{
client.setAccount(info.getLogin());
client.setState(LoginClientState.AUTHED_LOGIN);
client.setSessionKey(lc.assignSessionKeyToClient(info.getLogin(), client));
lc.getCharactersOnAccount(info.getLogin());
if (Config.SHOW_LICENCE)
{
client.sendPacket(new LoginOk(getClient().getSessionKey()));
}
else
{
getClient().sendPacket(new ServerList(getClient()));
}
break;
}
case INVALID_PASSWORD:
{
client.close(LoginFailReason.REASON_USER_OR_PASS_WRONG);
break;
}
case ACCOUNT_BANNED:
{
client.close(new AccountKicked(AccountKickedReason.REASON_PERMANENTLY_BANNED));
return;
}
case ALREADY_ON_LS:
{
final L2LoginClient oldClient = lc.getAuthedClient(info.getLogin());
if (oldClient != null)
{
// kick the other client
oldClient.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
lc.removeAuthedLoginClient(info.getLogin());
}
// kick also current client
client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
break;
}
case ALREADY_ON_GS:
{
final GameServerInfo gsi = lc.getAccountOnGameServer(info.getLogin());
if (gsi != null)
{
client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
// kick from there
if (gsi.isAuthed())
{
gsi.getGameServerThread().kickPlayer(info.getLogin());
}
}
break;
}
}
}
}

View File

@@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.clientpackets;
import com.l2jmobius.loginserver.network.serverpackets.LoginFail.LoginFailReason;
import com.l2jmobius.loginserver.network.serverpackets.ServerList;
/**
* <pre>
* Format: ddc
* d: fist part of session id
* d: second part of session id
* c: ?
* </pre>
*/
public class RequestServerList extends L2LoginClientPacket
{
private int _skey1;
private int _skey2;
private int _data3;
/**
* @return
*/
public int getSessionKey1()
{
return _skey1;
}
/**
* @return
*/
public int getSessionKey2()
{
return _skey2;
}
/**
* @return
*/
public int getData3()
{
return _data3;
}
@Override
public boolean readImpl()
{
if (super._buf.remaining() >= 8)
{
_skey1 = readD(); // loginOk 1
_skey2 = readD(); // loginOk 2
return true;
}
return false;
}
@Override
public void run()
{
if (getClient().getSessionKey().checkLoginPair(_skey1, _skey2))
{
getClient().sendPacket(new ServerList(getClient()));
}
else
{
getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
}
}
}

View File

@@ -0,0 +1,100 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.clientpackets;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.loginserver.SessionKey;
import com.l2jmobius.loginserver.network.serverpackets.LoginFail.LoginFailReason;
import com.l2jmobius.loginserver.network.serverpackets.PlayFail.PlayFailReason;
import com.l2jmobius.loginserver.network.serverpackets.PlayOk;
/**
* <pre>
* Format is ddc
* d: first part of session id
* d: second part of session id
* c: server ID
* </pre>
*/
public class RequestServerLogin extends L2LoginClientPacket
{
private int _skey1;
private int _skey2;
private int _serverId;
/**
* @return
*/
public int getSessionKey1()
{
return _skey1;
}
/**
* @return
*/
public int getSessionKey2()
{
return _skey2;
}
/**
* @return
*/
public int getServerID()
{
return _serverId;
}
@Override
public boolean readImpl()
{
if (super._buf.remaining() >= 9)
{
_skey1 = readD();
_skey2 = readD();
_serverId = readC();
return true;
}
return false;
}
@Override
public void run()
{
final SessionKey sk = getClient().getSessionKey();
// if we didnt showed the license we cant check these values
if (!Config.SHOW_LICENCE || sk.checkLoginPair(_skey1, _skey2))
{
if (LoginController.getInstance().isLoginPossible(getClient(), _serverId))
{
getClient().setJoinedGS(true);
getClient().sendPacket(new PlayOk(sk));
}
else
{
getClient().close(PlayFailReason.REASON_SERVER_OVERLOADED);
}
}
else
{
getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
}
}
}

View File

@@ -0,0 +1,78 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.security.GeneralSecurityException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Cipher;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler.GameServerState;
import com.l2jmobius.util.crypt.NewCrypt;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author -Wooden-
*/
public class BlowFishKey extends BaseRecievePacket
{
protected static final Logger _log = Logger.getLogger(BlowFishKey.class.getName());
/**
* @param decrypt
* @param server
*/
public BlowFishKey(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final int size = readD();
final byte[] tempKey = readB(size);
try
{
byte[] tempDecryptKey;
final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
rsaCipher.init(Cipher.DECRYPT_MODE, server.getPrivateKey());
tempDecryptKey = rsaCipher.doFinal(tempKey);
// there are nulls before the key we must remove them
int i = 0;
final int len = tempDecryptKey.length;
for (; i < len; i++)
{
if (tempDecryptKey[i] != 0)
{
break;
}
}
final byte[] key = new byte[len - i];
System.arraycopy(tempDecryptKey, i, key, 0, len - i);
server.SetBlowFish(new NewCrypt(key));
if (Config.DEBUG)
{
_log.info("New BlowFish key received, Blowfih Engine initialized:");
}
server.setLoginConnectionState(GameServerState.BF_CONNECTED);
}
catch (GeneralSecurityException e)
{
_log.log(Level.SEVERE, "Error While decrypting blowfish key (RSA): " + e.getMessage(), e);
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.logging.Logger;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author -Wooden-
*/
public class ChangeAccessLevel extends BaseRecievePacket
{
protected static Logger _log = Logger.getLogger(ChangeAccessLevel.class.getName());
/**
* @param decrypt
* @param server
*/
public ChangeAccessLevel(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final int level = readD();
final String account = readS();
LoginController.getInstance().setAccountAccessLevel(account, level);
_log.info("Changed " + account + " access level to " + level);
}
}

View File

@@ -0,0 +1,131 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.security.MessageDigest;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Base64;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author Nik
*/
public class ChangePassword extends BaseRecievePacket
{
protected static Logger _log = Logger.getLogger(ChangePassword.class.getName());
private static GameServerThread gst = null;
public ChangePassword(byte[] decrypt)
{
super(decrypt);
final String accountName = readS();
final String characterName = readS();
final String curpass = readS();
final String newpass = readS();
// get the GameServerThread
final Collection<GameServerInfo> serverList = GameServerTable.getInstance().getRegisteredGameServers().values();
for (GameServerInfo gsi : serverList)
{
if ((gsi.getGameServerThread() != null) && gsi.getGameServerThread().hasAccountOnGameServer(accountName))
{
gst = gsi.getGameServerThread();
}
}
if (gst == null)
{
return;
}
if ((curpass == null) || (newpass == null))
{
gst.ChangePasswordResponse((byte) 0, characterName, "Invalid password data! Try again.");
}
else
{
try
{
final MessageDigest md = MessageDigest.getInstance("SHA");
byte[] raw = curpass.getBytes("UTF-8");
raw = md.digest(raw);
final String curpassEnc = Base64.getEncoder().encodeToString(raw);
String pass = null;
int passUpdated = 0;
// SQL connection
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT password FROM accounts WHERE login=?"))
{
ps.setString(1, accountName);
try (ResultSet rs = ps.executeQuery())
{
if (rs.next())
{
pass = rs.getString("password");
}
}
}
if (curpassEnc.equals(pass))
{
byte[] password = newpass.getBytes("UTF-8");
password = md.digest(password);
// SQL connection
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET password=? WHERE login=?"))
{
ps.setString(1, Base64.getEncoder().encodeToString(password));
ps.setString(2, accountName);
passUpdated = ps.executeUpdate();
}
_log.log(Level.INFO, "The password for account " + accountName + " has been changed from " + curpassEnc + " to " + Base64.getEncoder().encodeToString(password));
if (passUpdated > 0)
{
gst.ChangePasswordResponse((byte) 1, characterName, "You have successfully changed your password!");
}
else
{
gst.ChangePasswordResponse((byte) 0, characterName, "The password change was unsuccessful!");
}
}
else
{
gst.ChangePasswordResponse((byte) 0, characterName, "The typed current password doesn't match with your current one.");
}
}
catch (Exception e)
{
_log.warning("Error while changing password for account " + accountName + " requested by player " + characterName + "! " + e);
}
}
}
}

View File

@@ -0,0 +1,177 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.Arrays;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.loginserver.network.L2JGameServerPacketHandler.GameServerState;
import com.l2jmobius.loginserver.network.loginserverpackets.AuthResponse;
import com.l2jmobius.loginserver.network.loginserverpackets.LoginServerFail;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* <pre>
* Format: cccddb
* c desired ID
* c accept alternative ID
* c reserve Host
* s ExternalHostName
* s InetranlHostName
* d max players
* d hexid size
* b hexid
* </pre>
*
* @author -Wooden-
*/
public class GameServerAuth extends BaseRecievePacket
{
protected static Logger _log = Logger.getLogger(GameServerAuth.class.getName());
GameServerThread _server;
private final byte[] _hexId;
private final int _desiredId;
@SuppressWarnings("unused")
private final boolean _hostReserved;
private final boolean _acceptAlternativeId;
private final int _maxPlayers;
private final int _port;
private final String[] _hosts;
/**
* @param decrypt
* @param server
*/
public GameServerAuth(byte[] decrypt, GameServerThread server)
{
super(decrypt);
_server = server;
_desiredId = readC();
_acceptAlternativeId = (readC() == 0 ? false : true);
_hostReserved = (readC() == 0 ? false : true);
_port = readH();
_maxPlayers = readD();
int size = readD();
_hexId = readB(size);
size = 2 * readD();
_hosts = new String[size];
for (int i = 0; i < size; i++)
{
_hosts[i] = readS();
}
if (Config.DEBUG)
{
_log.info("Auth request received");
}
if (handleRegProcess())
{
final AuthResponse ar = new AuthResponse(server.getGameServerInfo().getId());
server.sendPacket(ar);
if (Config.DEBUG)
{
_log.info("Authed: id: " + server.getGameServerInfo().getId());
}
server.broadcastToTelnet("GameServer [" + server.getServerId() + "] " + GameServerTable.getInstance().getServerNameById(server.getServerId()) + " is connected");
server.setLoginConnectionState(GameServerState.AUTHED);
}
}
private boolean handleRegProcess()
{
final GameServerTable gameServerTable = GameServerTable.getInstance();
final int id = _desiredId;
final byte[] hexId = _hexId;
GameServerInfo gsi = gameServerTable.getRegisteredGameServerById(id);
// is there a gameserver registered with this id?
if (gsi != null)
{
// does the hex id match?
if (Arrays.equals(gsi.getHexId(), hexId))
{
// check to see if this GS is already connected
synchronized (gsi)
{
if (gsi.isAuthed())
{
_server.forceClose(LoginServerFail.REASON_ALREADY_LOGGED8IN);
return false;
}
_server.attachGameServerInfo(gsi, _port, _hosts, _maxPlayers);
}
}
else
{
// there is already a server registered with the desired id and different hex id
// try to register this one with an alternative id
if (Config.ACCEPT_NEW_GAMESERVER && _acceptAlternativeId)
{
gsi = new GameServerInfo(id, hexId, _server);
if (gameServerTable.registerWithFirstAvailableId(gsi))
{
_server.attachGameServerInfo(gsi, _port, _hosts, _maxPlayers);
gameServerTable.registerServerOnDB(gsi);
}
else
{
_server.forceClose(LoginServerFail.REASON_NO_FREE_ID);
return false;
}
}
else
{
// server id is already taken, and we cant get a new one for you
_server.forceClose(LoginServerFail.REASON_WRONG_HEXID);
return false;
}
}
}
else
{
// can we register on this id?
if (Config.ACCEPT_NEW_GAMESERVER)
{
gsi = new GameServerInfo(id, hexId, _server);
if (gameServerTable.register(id, gsi))
{
_server.attachGameServerInfo(gsi, _port, _hosts, _maxPlayers);
gameServerTable.registerServerOnDB(gsi);
}
else
{
// some one took this ID meanwhile
_server.forceClose(LoginServerFail.REASON_ID_RESERVED);
return false;
}
}
else
{
_server.forceClose(LoginServerFail.REASON_WRONG_HEXID);
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,76 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.loginserver.SessionKey;
import com.l2jmobius.loginserver.network.loginserverpackets.PlayerAuthResponse;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author -Wooden-
*/
public class PlayerAuthRequest extends BaseRecievePacket
{
private static Logger _log = Logger.getLogger(PlayerAuthRequest.class.getName());
/**
* @param decrypt
* @param server
*/
public PlayerAuthRequest(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final String account = readS();
final int playKey1 = readD();
final int playKey2 = readD();
final int loginKey1 = readD();
final int loginKey2 = readD();
final SessionKey sessionKey = new SessionKey(loginKey1, loginKey2, playKey1, playKey2);
PlayerAuthResponse authResponse;
if (Config.DEBUG)
{
_log.info("auth request received for Player " + account);
}
final SessionKey key = LoginController.getInstance().getKeyForAccount(account);
if ((key != null) && key.equals(sessionKey))
{
if (Config.DEBUG)
{
_log.info("auth request: OK");
}
LoginController.getInstance().removeAuthedLoginClient(account);
authResponse = new PlayerAuthResponse(account, true);
}
else
{
if (Config.DEBUG)
{
_log.info("auth request: NO");
_log.info("session key from self: " + key);
_log.info("session key sent: " + sessionKey);
}
authResponse = new PlayerAuthResponse(account, false);
}
server.sendPacket(authResponse);
}
}

View File

@@ -0,0 +1,52 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author -Wooden-
*/
public class PlayerInGame extends BaseRecievePacket
{
private static Logger _log = Logger.getLogger(PlayerInGame.class.getName());
/**
* @param decrypt
* @param server
*/
public PlayerInGame(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final int size = readH();
for (int i = 0; i < size; i++)
{
final String account = readS();
server.addAccountOnGameServer(account);
if (Config.DEBUG)
{
_log.info("Account " + account + " logged in GameServer: [" + server.getServerId() + "] " + GameServerTable.getInstance().getServerNameById(server.getServerId()));
}
server.broadcastToTelnet("Account " + account + " logged in GameServer " + server.getServerId());
}
}
}

View File

@@ -0,0 +1,50 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author -Wooden-
*/
public class PlayerLogout extends BaseRecievePacket
{
protected static Logger _log = Logger.getLogger(PlayerLogout.class.getName());
/**
* @param decrypt
* @param server
*/
public PlayerLogout(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final String account = readS();
server.removeAccountOnGameServer(account);
if (Config.DEBUG)
{
_log.info("Player " + account + " logged out from gameserver [" + server.getServerId() + "] " + GameServerTable.getInstance().getServerNameById(server.getServerId()));
}
server.broadcastToTelnet("Player " + account + " disconnected from GameServer " + server.getServerId());
}
}

View File

@@ -0,0 +1,51 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author mrTJO
*/
public class PlayerTracert extends BaseRecievePacket
{
protected static Logger _log = Logger.getLogger(PlayerTracert.class.getName());
/**
* @param decrypt
*/
public PlayerTracert(byte[] decrypt)
{
super(decrypt);
final String account = readS();
final String pcIp = readS();
final String hop1 = readS();
final String hop2 = readS();
final String hop3 = readS();
final String hop4 = readS();
LoginController.getInstance().setAccountLastTracert(account, pcIp, hop1, hop2, hop3, hop4);
if (Config.DEBUG)
{
_log.info("Saved " + account + " last tracert");
}
}
}

View File

@@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* Thanks to mochitto.
* @author mrTJO
*/
public class ReplyCharacters extends BaseRecievePacket
{
/**
* @param decrypt
* @param server
*/
public ReplyCharacters(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final String account = readS();
final int chars = readC();
final int charsToDel = readC();
final long[] charsList = new long[charsToDel];
for (int i = 0; i < charsToDel; i++)
{
charsList[i] = readQ();
}
LoginController.getInstance().setCharactersOnServer(account, chars, charsList, server.getServerId());
}
}

View File

@@ -0,0 +1,83 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.net.UnknownHostException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.loginserver.LoginController;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author mrTJO
*/
public class RequestTempBan extends BaseRecievePacket
{
private static final Logger _log = Logger.getLogger(RequestTempBan.class.getName());
private final String _accountName;
@SuppressWarnings("unused")
private String _banReason;
private final String _ip;
long _banTime;
/**
* @param decrypt
*/
public RequestTempBan(byte[] decrypt)
{
super(decrypt);
_accountName = readS();
_ip = readS();
_banTime = readQ();
final boolean haveReason = readC() == 0 ? false : true;
if (haveReason)
{
_banReason = readS();
}
banUser();
}
private void banUser()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO account_data VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value=?"))
{
ps.setString(1, _accountName);
ps.setString(2, "ban_temp");
ps.setString(3, Long.toString(_banTime));
ps.setString(4, Long.toString(_banTime));
ps.execute();
}
catch (SQLException e)
{
_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
}
try
{
LoginController.getInstance().addBanForAddress(_ip, _banTime);
}
catch (UnknownHostException e)
{
}
}
}

View File

@@ -0,0 +1,112 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.gameserverpackets;
import java.util.logging.Logger;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
import com.l2jmobius.loginserver.GameServerThread;
import com.l2jmobius.util.network.BaseRecievePacket;
/**
* @author -Wooden-
*/
public class ServerStatus extends BaseRecievePacket
{
protected static Logger _log = Logger.getLogger(ServerStatus.class.getName());
public static final int SERVER_LIST_STATUS = 0x01;
public static final int SERVER_TYPE = 0x02;
public static final int SERVER_LIST_SQUARE_BRACKET = 0x03;
public static final int MAX_PLAYERS = 0x04;
public static final int TEST_SERVER = 0x05;
public static final int SERVER_AGE = 0x06;
// Server Status
public static final int STATUS_AUTO = 0x00;
public static final int STATUS_GOOD = 0x01;
public static final int STATUS_NORMAL = 0x02;
public static final int STATUS_FULL = 0x03;
public static final int STATUS_DOWN = 0x04;
public static final int STATUS_GM_ONLY = 0x05;
// Server Types
public static final int SERVER_NORMAL = 0x01;
public static final int SERVER_RELAX = 0x02;
public static final int SERVER_TEST = 0x04;
public static final int SERVER_NOLABEL = 0x08;
public static final int SERVER_CREATION_RESTRICTED = 0x10;
public static final int SERVER_EVENT = 0x20;
public static final int SERVER_FREE = 0x40;
// Server Ages
public static final int SERVER_AGE_ALL = 0x00;
public static final int SERVER_AGE_15 = 0x0F;
public static final int SERVER_AGE_18 = 0x12;
public static final int ON = 0x01;
public static final int OFF = 0x00;
/**
* @param decrypt
* @param server
*/
public ServerStatus(byte[] decrypt, GameServerThread server)
{
super(decrypt);
final GameServerInfo gsi = GameServerTable.getInstance().getRegisteredGameServerById(server.getServerId());
if (gsi != null)
{
final int size = readD();
for (int i = 0; i < size; i++)
{
final int type = readD();
final int value = readD();
switch (type)
{
case SERVER_LIST_STATUS:
{
gsi.setStatus(value);
break;
}
case SERVER_LIST_SQUARE_BRACKET:
{
gsi.setShowingBrackets(value == ON);
break;
}
case MAX_PLAYERS:
{
gsi.setMaxPlayers(value);
break;
}
case SERVER_TYPE:
{
gsi.setServerType(value);
break;
}
case SERVER_AGE:
{
gsi.setAgeLimit(value);
break;
}
}
}
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author -Wooden-
*/
public class AuthResponse extends BaseSendablePacket
{
/**
* @param serverId
*/
public AuthResponse(int serverId)
{
writeC(0x02);
writeC(serverId);
writeS(GameServerTable.getInstance().getServerNameById(serverId));
}
@Override
public byte[] getContent()
{
return getBytes();
}
}

View File

@@ -0,0 +1,39 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author Nik
*/
public class ChangePasswordResponse extends BaseSendablePacket
{
public ChangePasswordResponse(byte successful, String characterName, String msgToSend)
{
writeC(0x06);
// writeC(successful); //0 false, 1 true
writeS(characterName);
writeS(msgToSend);
}
@Override
public byte[] getContent()
{
return getBytes();
}
}

View File

@@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.loginserver.L2LoginServer;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author -Wooden-
*/
public class InitLS extends BaseSendablePacket
{
// ID 0x00
// format
// d proto rev
// d key size
// b key
public InitLS(byte[] publickey)
{
writeC(0x00);
writeD(L2LoginServer.PROTOCOL_REV);
writeD(publickey.length);
writeB(publickey);
}
@Override
public byte[] getContent()
{
return getBytes();
}
}

View File

@@ -0,0 +1,37 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author -Wooden-
*/
public class KickPlayer extends BaseSendablePacket
{
public KickPlayer(String account)
{
writeC(0x04);
writeS(account);
}
@Override
public byte[] getContent()
{
return getBytes();
}
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author -Wooden-
*/
public class LoginServerFail extends BaseSendablePacket
{
/**
* @param reason
*/
public LoginServerFail(int reason)
{
writeC(0x01);
writeC(reason);
}
@Override
public byte[] getContent()
{
return getBytes();
}
public static final int REASON_IP_BANNED = 1;
public static final int REASON_IP_RESERVED = 2;
public static final int REASON_WRONG_HEXID = 3;
public static final int REASON_ID_RESERVED = 4;
public static final int REASON_NO_FREE_ID = 5;
public static final int NOT_AUTHED = 6;
public static final int REASON_ALREADY_LOGGED8IN = 7;
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author -Wooden-
*/
public class PlayerAuthResponse extends BaseSendablePacket
{
public PlayerAuthResponse(String account, boolean response)
{
writeC(0x03);
writeS(account);
writeC(response ? 1 : 0);
}
@Override
public byte[] getContent()
{
return getBytes();
}
}

View File

@@ -0,0 +1,37 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.loginserverpackets;
import com.l2jmobius.util.network.BaseSendablePacket;
/**
* @author mrTJO
*/
public class RequestCharacters extends BaseSendablePacket
{
public RequestCharacters(String account)
{
writeC(0x05);
writeS(account);
}
@Override
public byte[] getContent()
{
return getBytes();
}
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
/**
* @author KenM
*/
public final class AccountKicked extends L2LoginServerPacket
{
public static enum AccountKickedReason
{
REASON_DATA_STEALER(0x01),
REASON_GENERIC_VIOLATION(0x08),
REASON_7_DAYS_SUSPENDED(0x10),
REASON_PERMANENTLY_BANNED(0x20);
private final int _code;
AccountKickedReason(int code)
{
_code = code;
}
public final int getCode()
{
return _code;
}
}
private final AccountKickedReason _reason;
/**
* @param reason
*/
public AccountKicked(AccountKickedReason reason)
{
_reason = reason;
}
@Override
protected void write()
{
writeC(0x02);
writeD(_reason.getCode());
}
}

View File

@@ -0,0 +1,52 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
import java.util.logging.Logger;
import com.l2jmobius.Config;
/**
* Fromat: d d: response
*/
public final class GGAuth extends L2LoginServerPacket
{
static final Logger _log = Logger.getLogger(GGAuth.class.getName());
public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
private final int _response;
public GGAuth(int response)
{
_response = response;
if (Config.DEBUG)
{
_log.warning("Reason Hex: " + (Integer.toHexString(response)));
}
}
@Override
protected void write()
{
writeC(0x0b);
writeD(_response);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
}
}

View File

@@ -0,0 +1,73 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
import com.l2jmobius.loginserver.network.L2LoginClient;
/**
* <pre>
* 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
* </pre>
*/
public final class Init extends L2LoginServerPacket
{
private final int _sessionId;
private final byte[] _publicKey;
private final byte[] _blowfishKey;
public Init(L2LoginClient client)
{
this(client.getScrambledModulus(), client.getBlowfishKey(), client.getSessionId());
}
public Init(byte[] publickey, byte[] blowfishkey, int sessionId)
{
_sessionId = sessionId;
_publicKey = publickey;
_blowfishKey = blowfishkey;
}
@Override
protected void write()
{
writeC(0x00); // init packet id
writeD(_sessionId); // session id
writeD(0x0000c621); // protocol revision
writeB(_publicKey); // RSA Public Key
// unk GG related?
writeD(0x29DD954E);
writeD(0x77C39CFC);
writeD(0x97ADB620);
writeD(0x07BDE0F7);
writeB(_blowfishKey); // BlowFish key
writeC(0x00); // null termination ;)
}
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
import com.l2jmobius.commons.mmocore.SendablePacket;
import com.l2jmobius.loginserver.network.L2LoginClient;
/**
* @author KenM
*/
public abstract class L2LoginServerPacket extends SendablePacket<L2LoginClient>
{
}

View File

@@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
/**
* Fromat: d d: the failure reason
*/
public final class LoginFail extends L2LoginServerPacket
{
public static enum LoginFailReason
{
REASON_NO_MESSAGE(0x00),
REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
REASON_USER_OR_PASS_WRONG(0x02),
REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
REASON_ACCOUNT_IN_USE(0x07),
REASON_UNDER_18_YEARS_KR(0x0C),
REASON_SERVER_OVERLOADED(0x0F),
REASON_SERVER_MAINTENANCE(0x10),
REASON_TEMP_PASS_EXPIRED(0x11),
REASON_GAME_TIME_EXPIRED(0x12),
REASON_NO_TIME_LEFT(0x13),
REASON_SYSTEM_ERROR(0x14),
REASON_ACCESS_FAILED(0x15),
REASON_RESTRICTED_IP(0x16),
REASON_WEEK_USAGE_FINISHED(0x1E),
REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
REASON_DUAL_BOX(0x23),
REASON_INACTIVE(0x24),
REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
REASON_ACCOUNT_SUSPENDED_CALL(0x28),
REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
REASON_CERTIFICATION_FAILED(0x2E),
REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
private final int _code;
LoginFailReason(int code)
{
_code = code;
}
public final int getCode()
{
return _code;
}
}
private final LoginFailReason _reason;
public LoginFail(LoginFailReason reason)
{
_reason = reason;
}
@Override
protected void write()
{
writeC(0x01);
writeC(_reason.getCode());
}
}

View File

@@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
import com.l2jmobius.loginserver.SessionKey;
/**
* <pre>
* Format: dddddddd
* f: the session key
* d: ?
* d: ?
* d: ?
* d: ?
* d: ?
* d: ?
* b: 16 bytes - unknown
* </pre>
*/
public final class LoginOk extends L2LoginServerPacket
{
private final int _loginOk1, _loginOk2;
public LoginOk(SessionKey sessionKey)
{
_loginOk1 = sessionKey.loginOkID1;
_loginOk2 = sessionKey.loginOkID2;
}
@Override
protected void write()
{
writeC(0x03);
writeD(_loginOk1);
writeD(_loginOk2);
writeD(0x00);
writeD(0x00);
writeD(0x000003ea);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeB(new byte[16]);
}
}

View File

@@ -0,0 +1,93 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
/**
* This class ...
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:11 $
*/
public final class PlayFail extends L2LoginServerPacket
{
public static enum PlayFailReason
{
REASON_NO_MESSAGE(0x00),
REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
REASON_USER_OR_PASS_WRONG(0x02),
REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
REASON_ACCOUNT_IN_USE(0x07),
REASON_UNDER_18_YEARS_KR(0x0C),
REASON_SERVER_OVERLOADED(0x0F),
REASON_SERVER_MAINTENANCE(0x10),
REASON_TEMP_PASS_EXPIRED(0x11),
REASON_GAME_TIME_EXPIRED(0x12),
REASON_NO_TIME_LEFT(0x13),
REASON_SYSTEM_ERROR(0x14),
REASON_ACCESS_FAILED(0x15),
REASON_RESTRICTED_IP(0x16),
REASON_WEEK_USAGE_FINISHED(0x1E),
REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
REASON_DUAL_BOX(0x23),
REASON_INACTIVE(0x24),
REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
REASON_ACCOUNT_SUSPENDED_CALL(0x28),
REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
REASON_CERTIFICATION_FAILED(0x2E),
REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
private final int _code;
PlayFailReason(int code)
{
_code = code;
}
public final int getCode()
{
return _code;
}
}
private final PlayFailReason _reason;
public PlayFail(PlayFailReason reason)
{
_reason = reason;
}
@Override
protected void write()
{
writeC(0x06);
writeC(_reason.getCode());
}
}

View File

@@ -0,0 +1,41 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
import com.l2jmobius.loginserver.SessionKey;
/**
*
*/
public final class PlayOk extends L2LoginServerPacket
{
private final int _playOk1, _playOk2;
public PlayOk(SessionKey sessionKey)
{
_playOk1 = sessionKey.playOkID1;
_playOk2 = sessionKey.playOkID2;
}
@Override
protected void write()
{
writeC(0x07);
writeD(_playOk1);
writeD(_playOk2);
}
}

View File

@@ -0,0 +1,174 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.loginserver.network.serverpackets;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.loginserver.GameServerTable;
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
import com.l2jmobius.loginserver.network.L2LoginClient;
import com.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
/**
* ServerList
*
* <pre>
* Format: cc [cddcchhcdc]
*
* c: server list size (number of servers)
* c: ?
* [ (repeat for each servers)
* c: server id (ignored by client?)
* d: server ip
* d: server port
* c: age limit (used by client?)
* c: pvp or not (used by client?)
* h: current number of players
* h: max number of players
* c: 0 if server is down
* d: 2nd bit: clock
* 3rd bit: won't display server name
* 4th bit: test server (used by client?)
* c: 0 if you don't want to display brackets in front of sever name
* ]
* </pre>
*
* Server will be considered as Good when the number of online players<br>
* is less than half the maximum. as Normal between half and 4/5<br>
* and Full when there's more than 4/5 of the maximum number of players.
*/
public final class ServerList extends L2LoginServerPacket
{
protected static final Logger _log = Logger.getLogger(ServerList.class.getName());
private final List<ServerData> _servers;
private final int _lastServer;
private final Map<Integer, Integer> _charsOnServers;
private final Map<Integer, long[]> _charsToDelete;
class ServerData
{
protected byte[] _ip;
protected int _port;
protected int _ageLimit;
protected boolean _pvp;
protected int _currentPlayers;
protected int _maxPlayers;
protected boolean _brackets;
protected boolean _clock;
protected int _status;
protected int _serverId;
protected int _serverType;
ServerData(L2LoginClient client, GameServerInfo gsi)
{
try
{
_ip = InetAddress.getByName(gsi.getServerAddress(client.getConnection().getInetAddress())).getAddress();
}
catch (UnknownHostException e)
{
_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
_ip = new byte[4];
_ip[0] = 127;
_ip[1] = 0;
_ip[2] = 0;
_ip[3] = 1;
}
_port = gsi.getPort();
_pvp = gsi.isPvp();
_serverType = gsi.getServerType();
_currentPlayers = gsi.getCurrentPlayerCount();
_maxPlayers = gsi.getMaxPlayers();
_ageLimit = 0;
_brackets = gsi.isShowingBrackets();
// If server GM-only - show status only to GMs
_status = gsi.getStatus() != ServerStatus.STATUS_GM_ONLY ? gsi.getStatus() : client.getAccessLevel() > 0 ? gsi.getStatus() : ServerStatus.STATUS_DOWN;
_serverId = gsi.getId();
}
}
public ServerList(L2LoginClient client)
{
_servers = new ArrayList<>(GameServerTable.getInstance().getRegisteredGameServers().size());
_lastServer = client.getLastServer();
for (GameServerInfo gsi : GameServerTable.getInstance().getRegisteredGameServers().values())
{
_servers.add(new ServerData(client, gsi));
}
_charsOnServers = client.getCharsOnServ();
_charsToDelete = client.getCharsWaitingDelOnServ();
}
@Override
public void write()
{
writeC(0x04);
writeC(_servers.size());
writeC(_lastServer);
for (ServerData server : _servers)
{
writeC(server._serverId); // server id
writeC(server._ip[0] & 0xff);
writeC(server._ip[1] & 0xff);
writeC(server._ip[2] & 0xff);
writeC(server._ip[3] & 0xff);
writeD(server._port);
writeC(server._ageLimit); // Age Limit 0, 15, 18
writeC(server._pvp ? 0x01 : 0x00);
writeH(server._currentPlayers);
writeH(server._maxPlayers);
writeC(server._status == ServerStatus.STATUS_DOWN ? 0x00 : 0x01);
writeD(server._serverType); // 1: Normal, 2: Relax, 4: Public Test, 8: No Label, 16: Character Creation Restricted, 32: Event, 64: Free
writeC(server._brackets ? 0x01 : 0x00);
}
writeH(0x00); // unknown
if (_charsOnServers != null)
{
writeC(_charsOnServers.size());
for (int servId : _charsOnServers.keySet())
{
writeC(servId);
writeC(_charsOnServers.get(servId));
if ((_charsToDelete == null) || !_charsToDelete.containsKey(servId))
{
writeC(0x00);
}
else
{
writeC(_charsToDelete.get(servId).length);
for (long deleteTime : _charsToDelete.get(servId))
{
writeD((int) ((deleteTime - System.currentTimeMillis()) / 1000));
}
}
}
}
else
{
writeC(0x00);
}
}
}