Browse Source

BETA: Implementation of Secondary Auth feature (by mrTJO)

Rumen Nikiforov 14 năm trước cách đây
mục cha
commit
e0937aa271
69 tập tin đã thay đổi với 4528 bổ sung3003 xóa
  1. 12 9
      L2J_Server_BETA/.classpath
  2. 5 0
      L2J_Server_BETA/build.xml
  3. 72 5
      L2J_Server_BETA/java/com/l2jserver/Config.java
  4. 6 0
      L2J_Server_BETA/java/com/l2jserver/accountmanager/SQLAccountManager.java
  5. 2 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java
  6. 36 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/LoginServerThread.java
  7. 1 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/idfactory/IdFactory.java
  8. 13 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/L2GameClient.java
  9. 15 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java
  10. 6 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/CharacterSelect.java
  11. 56 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEx2ndPasswordCheck.java
  12. 71 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEx2ndPasswordReq.java
  13. 55 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEx2ndPasswordVerify.java
  14. 48 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/gameserverpackets/SendMail.java
  15. 56 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/gameserverpackets/TempBan.java
  16. 54 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/Ex2ndPasswordAck.java
  17. 54 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/Ex2ndPasswordCheck.java
  18. 52 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/Ex2ndPasswordVerify.java
  19. 327 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/security/SecondaryPasswordAuth.java
  20. 2 2
      L2J_Server_BETA/java/com/l2jserver/loginserver/GameServerTable.java
  21. 73 461
      L2J_Server_BETA/java/com/l2jserver/loginserver/GameServerThread.java
  22. 11 2
      L2J_Server_BETA/java/com/l2jserver/loginserver/L2LoginServer.java
  23. 23 13
      L2J_Server_BETA/java/com/l2jserver/loginserver/LoginController.java
  24. 2 1
      L2J_Server_BETA/java/com/l2jserver/loginserver/SelectorHelper.java
  25. 0 108
      L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/GameServerAuth.java
  26. 0 93
      L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/PlayerTracert.java
  27. 178 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/mail/BaseMail.java
  28. 148 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/mail/MailSystem.java
  29. 105 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/L2JGameServerPacketHandler.java
  30. 297 295
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/L2LoginClient.java
  31. 94 92
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/L2LoginPacketHandler.java
  32. 96 96
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/AuthGameGuard.java
  33. 50 50
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/L2LoginClientPacket.java
  34. 173 173
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/RequestAuthLogin.java
  35. 86 86
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/RequestServerList.java
  36. 102 102
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/RequestServerLogin.java
  37. 74 76
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/BlowFishKey.java
  38. 43 55
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/ChangeAccessLevel.java
  39. 172 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/GameServerAuth.java
  40. 74 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerAuthRequest.java
  41. 50 53
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerInGame.java
  42. 48 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerLogout.java
  43. 50 61
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerTracert.java
  44. 44 75
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/ReplyCharacters.java
  45. 46 45
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/RequestSendMail.java
  46. 84 0
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/RequestTempBan.java
  47. 103 102
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/ServerStatus.java
  48. 49 49
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/AuthResponse.java
  49. 45 45
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/InitLS.java
  50. 43 43
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/KickPlayer.java
  51. 49 49
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/LoginServerFail.java
  52. 44 44
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/PlayerAuthResponse.java
  53. 42 42
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/RequestCharacters.java
  54. 60 60
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/AccountKicked.java
  55. 56 56
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/GGAuth.java
  56. 73 73
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/Init.java
  57. 29 29
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/L2LoginServerPacket.java
  58. 95 95
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/LoginFail.java
  59. 57 57
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/LoginOk.java
  60. 96 96
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/PlayFail.java
  61. 42 42
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/PlayOk.java
  62. 160 160
      L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/ServerList.java
  63. 0 4
      L2J_Server_BETA/java/config/General.properties
  64. 57 0
      L2J_Server_BETA/java/config/email.properties
  65. 25 0
      L2J_Server_BETA/java/config/security.properties
  66. BIN
      L2J_Server_BETA/lib/mail.jar
  67. 337 0
      L2J_Server_BETA/lib/mail_LICENSE.txt
  68. BIN
      L2J_Server_BETA/lib/mailapi.jar
  69. BIN
      L2J_Server_BETA/lib/smtp.jar

+ 12 - 9
L2J_Server_BETA/.classpath

@@ -4,13 +4,16 @@
 	<classpathentry excluding="**/.svn/*|.svn" kind="src" path="javaTest" />
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" />
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4" />
-	<classpathentry kind="lib" path="lib/jython.jar" />
-	<classpathentry kind="lib" path="lib/c3p0-0.9.2-pre1.jar" />
-	<classpathentry kind="lib" path="lib/mchange-commons-0.2.jar" />
-	<classpathentry kind="lib" path="lib/mmocore.jar" />
-	<classpathentry kind="lib" path="lib/netcon.jar" />
-	<classpathentry kind="lib" path="lib/jython-engine.jar" />
-	<classpathentry kind="lib" path="lib/trove-2.1.0.jar" />
-	<classpathentry kind="lib" path="lib/javolution-5.5.1.jar" />
-	<classpathentry kind="output" path="bin" />
+	<classpathentry kind="lib" path="lib/c3p0-0.9.2-pre1.jar"/>
+	<classpathentry kind="lib" path="lib/javolution-5.5.1.jar"/>
+	<classpathentry kind="lib" path="lib/jython-engine.jar"/>
+	<classpathentry kind="lib" path="lib/jython.jar"/>
+	<classpathentry kind="lib" path="lib/mchange-commons-0.2.jar"/>
+	<classpathentry kind="lib" path="lib/mmocore.jar"/>
+	<classpathentry kind="lib" path="lib/netcon.jar"/>
+	<classpathentry kind="lib" path="lib/trove-2.1.0.jar"/>
+	<classpathentry kind="lib" path="lib/mail.jar"/>
+	<classpathentry kind="lib" path="lib/mailapi.jar"/>
+	<classpathentry kind="lib" path="lib/smtp.jar"/>
+	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 5 - 0
L2J_Server_BETA/build.xml

@@ -43,6 +43,9 @@
 			<include name="mmocore.jar" />
 			<include name="trove-2.1.0.jar" />
 			<include name="netcon.jar" />
+			<include name="mail.jar" />
+			<include name="mailapi.jar" />
+			<include name="smtp.jar" />
 		</fileset>
 	</path>
 
@@ -186,6 +189,7 @@
 				<include name="*.xsd" />
 				<include name="*.txt" />
 				<exclude name="loginserver.properties" />
+				<exclude name="email.properties" />
 			</fileset>
 		</copy>
 		<copy todir="${build.dist.login}/config">
@@ -193,6 +197,7 @@
 				<include name="loginserver.properties" />
 				<include name="mmo.properties" />
 				<include name="telnet.properties" />
+				<include name="email.properties" />
 			</fileset>
 		</copy>
 		<mkdir dir="${build.dist.game}/data" />

+ 72 - 5
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -81,6 +81,8 @@ public final class Config
 	public static final String GRANDBOSS_CONFIG_FILE = "./config/Grandboss.properties";
 	public static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.properties";
 	public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
+	public static final String SECURITY_CONFIG_FILE = "./config/security.properties";
+	public static final String EMAIL_CONFIG_FILE = "./config/email.properties";
 	
 	
 	//--------------------------------------------------
@@ -420,7 +422,6 @@ public final class Config
 	public static boolean PACKET_HANDLER_DEBUG;
 	public static boolean DEVELOPER;
 	public static boolean ACCEPT_GEOEDITOR_CONN;
-	public static boolean TEST_SERVER;
 	public static boolean ALT_DEV_NO_HANDLERS;
 	public static boolean ALT_DEV_NO_QUESTS;
 	public static boolean ALT_DEV_NO_SPAWNS;
@@ -1028,6 +1029,28 @@ public final class Config
 	//chatfilter
 	public static ArrayList<String>	FILTER_LIST;
 	
+	// Security
+	public static boolean SECOND_AUTH_ENABLED;
+	public static int SECOND_AUTH_MAX_ATTEMPTS;
+	public static long SECOND_AUTH_BAN_TIME;
+	public static String SECOND_AUTH_REC_LINK;
+	
+	public static String EMAIL_SERVERINFO_NAME;
+	public static String EMAIL_SERVERINFO_ADDRESS;
+	
+	// Email
+	public static boolean EMAIL_SYS_ENABLED;
+	public static String EMAIL_SYS_HOST;
+	public static int EMAIL_SYS_PORT;
+	public static boolean EMAIL_SYS_SMTP_AUTH;
+	public static String EMAIL_SYS_FACTORY;
+	public static boolean EMAIL_SYS_FACTORY_CALLBACK;
+	public static String EMAIL_SYS_USERNAME;
+	public static String EMAIL_SYS_PASSWORD;
+	public static String EMAIL_SYS_ADDRESS;
+	
+	
+	
 	/**
 	 * This class initializes all global variables for configuration.<br>
 	 * If the key doesn't appear in properties file, a default value is set by this class.
@@ -1809,7 +1832,6 @@ public final class Config
 					PACKET_HANDLER_DEBUG = Boolean.parseBoolean(General.getProperty("PacketHandlerDebug", "false"));
 					DEVELOPER = Boolean.parseBoolean(General.getProperty("Developer", "false"));
 					ACCEPT_GEOEDITOR_CONN = Boolean.parseBoolean(General.getProperty("AcceptGeoeditorConn", "false"));
-					TEST_SERVER = Boolean.parseBoolean(General.getProperty("TestServer", "false"));
 					ALT_DEV_NO_HANDLERS = Boolean.parseBoolean(General.getProperty("AltDevNoHandlers", "False"));
 					ALT_DEV_NO_QUESTS = Boolean.parseBoolean(General.getProperty("AltDevNoQuests", "False"));
 					ALT_DEV_NO_SPAWNS = Boolean.parseBoolean(General.getProperty("AltDevNoSpawns", "False"));
@@ -2773,6 +2795,25 @@ public final class Config
 					e.printStackTrace();
 					throw new Error("Failed to Load " + CHAT_FILTER_FILE + " File.");
 				}
+				
+				// Security
+				try
+				{
+					L2Properties securitySettings = new L2Properties();
+					is = new FileInputStream(new File(SECURITY_CONFIG_FILE));
+					securitySettings.load(is);
+
+					// Second Auth Settings
+					SECOND_AUTH_ENABLED = Boolean.parseBoolean(securitySettings.getProperty("SecondAuthEnabled", "false"));
+					SECOND_AUTH_MAX_ATTEMPTS = Integer.parseInt(securitySettings.getProperty("SecondAuthMaxAttempts", "5"));
+					SECOND_AUTH_BAN_TIME = Integer.parseInt(securitySettings.getProperty("SecondAuthBanTime", "480"));
+					SECOND_AUTH_REC_LINK = securitySettings.getProperty("SecondAuthRecoveryLink", "5");
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+					throw new Error("Failed to Load " + SECURITY_CONFIG_FILE + " File.");
+				}
 			}
 			finally
 			{
@@ -2868,6 +2909,32 @@ public final class Config
 					e.printStackTrace();
 					throw new Error("Failed to Load "+TELNET_FILE+" File.");
 				}
+				
+				// Email
+				try
+				{
+					L2Properties emailSettings = new L2Properties();
+					is = new FileInputStream(new File(EMAIL_CONFIG_FILE));
+					emailSettings.load(is);
+					
+					EMAIL_SERVERINFO_NAME = emailSettings.getProperty("ServerInfoName", "Unconfigured L2J Server");
+					EMAIL_SERVERINFO_ADDRESS = emailSettings.getProperty("ServerInfoAddress", "info@myl2jserver.com");
+					
+					EMAIL_SYS_ENABLED = Boolean.parseBoolean(emailSettings.getProperty("EmailSystemEnabled", "false"));
+					EMAIL_SYS_HOST = emailSettings.getProperty("SmtpServerHost", "smtp.gmail.com");
+					EMAIL_SYS_PORT = Integer.parseInt(emailSettings.getProperty("SmtpServerPort", "465"));
+					EMAIL_SYS_SMTP_AUTH = Boolean.parseBoolean(emailSettings.getProperty("SmtpAuthRequired", "true"));
+					EMAIL_SYS_FACTORY = emailSettings.getProperty("SmtpFactory", "javax.net.ssl.SSLSocketFactory");
+					EMAIL_SYS_FACTORY_CALLBACK = Boolean.parseBoolean(emailSettings.getProperty("SmtpFactoryCallback", "false"));
+					EMAIL_SYS_USERNAME = emailSettings.getProperty("SmtpUsername", "user@gmail.com");
+					EMAIL_SYS_PASSWORD = emailSettings.getProperty("SmtpPassword", "password");
+					EMAIL_SYS_ADDRESS = emailSettings.getProperty("EmailSystemAddress", "noreply@myl2jserver.com");
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+					throw new Error("Failed to Load " + EMAIL_CONFIG_FILE + " File.");
+				}
 			}
 			finally
 			{
@@ -3394,9 +3461,9 @@ public final class Config
 	
 	public static class ClassMasterSettings
 	{
-		private TIntObjectHashMap<TIntIntHashMap> _claimItems;
-		private TIntObjectHashMap<TIntIntHashMap> _rewardItems;
-		private TIntObjectHashMap<Boolean> _allowedClassChange;
+		private final TIntObjectHashMap<TIntIntHashMap> _claimItems;
+		private final TIntObjectHashMap<TIntIntHashMap> _rewardItems;
+		private final TIntObjectHashMap<Boolean> _allowedClassChange;
 		
 		public ClassMasterSettings(String _configLine)
 		{

+ 6 - 0
L2J_Server_BETA/java/com/l2jserver/accountmanager/SQLAccountManager.java

@@ -449,6 +449,12 @@ public class SQLAccountManager
 				// TODO: delete pets, olympiad/noble/hero stuff
 			}
 			
+			// characters
+			statement.close();
+			statement = con.prepareStatement("DELETE FROM account_gsdata WHERE account_name=?;");
+			statement.setString(1, account);
+			statement.executeUpdate();
+			
 			// Delete Account
 			statement.close();
 			statement = con.prepareStatement("DELETE FROM accounts WHERE login=?;");

+ 2 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java

@@ -15,6 +15,7 @@
 
 package com.l2jserver.gameserver;
 
+import java.awt.Toolkit;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -424,6 +425,7 @@ public class GameServer
 		long freeMem = (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory()) / 1048576;
 		long totalMem = Runtime.getRuntime().maxMemory() / 1048576;
 		_log.info("GameServer Started, free memory " + freeMem + " Mb of " + totalMem + " Mb");
+		Toolkit.getDefaultToolkit().beep();
 		
 		_loginThread = LoginServerThread.getInstance();
 		_loginThread.start();

+ 36 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/LoginServerThread.java

@@ -20,6 +20,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;
@@ -56,7 +57,9 @@ import com.l2jserver.gameserver.network.gameserverpackets.PlayerInGame;
 import com.l2jserver.gameserver.network.gameserverpackets.PlayerLogout;
 import com.l2jserver.gameserver.network.gameserverpackets.PlayerTracert;
 import com.l2jserver.gameserver.network.gameserverpackets.ReplyCharacters;
+import com.l2jserver.gameserver.network.gameserverpackets.SendMail;
 import com.l2jserver.gameserver.network.gameserverpackets.ServerStatus;
+import com.l2jserver.gameserver.network.gameserverpackets.TempBan;
 import com.l2jserver.gameserver.network.loginserverpackets.AuthResponse;
 import com.l2jserver.gameserver.network.loginserverpackets.InitLS;
 import com.l2jserver.gameserver.network.loginserverpackets.KickPlayer;
@@ -76,7 +79,7 @@ public class LoginServerThread extends Thread
 	protected static final Logger _logAccounting = Logger.getLogger("accounting");
 	
 	/** {@see com.l2jserver.loginserver.LoginServer#PROTOCOL_REV } */
-	private static final int REVISION = 0x0105;
+	private static final int REVISION = 0x0106;
 	private RSAPublicKey _publicKey;
 	private String _hostname;
 	private int _port;
@@ -354,6 +357,10 @@ public class LoginServerThread extends Thread
 				if (Config.DEBUG)
 					_log.log(Level.WARNING, "", e);
 			}
+			catch (SocketException e)
+			{
+				_log.warning("LoginServer not avaible, trying to reconnect...");
+			}
 			catch (IOException e)
 			{
 				_log.log(Level.WARNING, "Disconnected from Login, Trying to reconnect: " + e.getMessage(), e);
@@ -476,6 +483,34 @@ public class LoginServerThread extends Thread
 		}
 	}
 	
+	public void sendMail(String account, String mailId, String... args)
+	{
+		SendMail sem = new SendMail(account, mailId, args);
+		try
+		{
+			sendPacket(sem);
+		}
+		catch (IOException e)
+		{
+			if (Config.DEBUG)
+				_log.log(Level.WARNING, "", e);
+		}
+	}
+	
+	public void sendTempBan(String account, String ip, long time)
+	{
+		TempBan tbn = new TempBan(account, ip, time);
+		try
+		{
+			sendPacket(tbn);
+		}
+		catch (IOException e)
+		{
+			if (Config.DEBUG)
+				_log.log(Level.WARNING, "", e);
+		}
+	}
+	
 	private String hexToString(byte[] hex)
 	{
 		return new BigInteger(hex).toString(16);

+ 1 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/idfactory/IdFactory.java

@@ -203,6 +203,7 @@ public abstract class IdFactory
 			// stmt.executeUpdate("DELETE FROM characters WHERE characters.account_name NOT IN (SELECT login FROM accounts);");
 			
 			// If the character does not exist...
+			cleanCount += stmt.executeUpdate("DELETE FROM account_gsdata WHERE account_gsdata.account_name NOT IN (SELECT account_name FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_contacts WHERE character_contacts.charId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_contacts WHERE character_contacts.contactId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_friends WHERE character_friends.charId NOT IN (SELECT charId FROM characters);");

+ 13 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/network/L2GameClient.java

@@ -50,6 +50,7 @@ import com.l2jserver.gameserver.model.entity.TvTEvent;
 import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
 import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
 import com.l2jserver.gameserver.network.serverpackets.ServerClose;
+import com.l2jserver.gameserver.security.SecondaryPasswordAuth;
 import com.l2jserver.gameserver.util.FloodProtectors;
 import com.l2jserver.gameserver.util.Util;
 
@@ -78,6 +79,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 	private SessionKey _sessionId;
 	private L2PcInstance _activeChar;
 	private final ReentrantLock _activeCharLock = new ReentrantLock();
+	private SecondaryPasswordAuth _secondaryAuth;
 	
 	private boolean _isAuthedGG;
 	private final long _connectionStartTime;
@@ -230,6 +232,9 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 	public void setAccountName(String pAccountName)
 	{
 		_accountName = pAccountName;
+		
+		if (Config.SECOND_AUTH_ENABLED)
+			_secondaryAuth = new SecondaryPasswordAuth(this);
 	}
 	
 	public String getAccountName()
@@ -407,9 +412,6 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 		_logAccounting.log(record);
 	}
 	
-	
-	
-	
 	public static void deleteCharByObjId(int objid)
 	{
 		if (objid < 0)
@@ -601,6 +603,11 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 			return null;
 		return _charSlotMapping[charslot];
 	}
+	
+	public SecondaryPasswordAuth getSecondaryAuth()
+	{
+		return _secondaryAuth;
+	}
 
 	public void close(L2GameServerPacket gsp)
 	{
@@ -704,6 +711,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 		/**
 		 * @see java.lang.Runnable#run()
 		 */
+		@Override
 		public void run()
 		{
 			boolean fast = true;
@@ -787,6 +795,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 		/**
 		 * @see java.lang.Runnable#run()
 		 */
+		@Override
 		public void run()
 		{
 			try
@@ -836,6 +845,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 	
 	class AutoSaveTask implements Runnable
 	{
+		@Override
 		public void run()
 		{
 			try

+ 15 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java

@@ -118,6 +118,21 @@ public final class L2GamePacketHandler implements IPacketHandler<L2GameClient>,
 							case 0x5a:
 								msg = new RequestExCubeGameChangeTeam();
 								break;
+							//case 0xad:
+							case 0x93:
+								msg = new RequestEx2ndPasswordCheck();
+								break;
+							//case 0xae:
+							case 0x94:
+								msg = new RequestEx2ndPasswordVerify();
+								break;
+							//case 0xaf:
+							case 0x95:
+								msg = new RequestEx2ndPasswordReq();
+								break;
+							/*case 0xb0:
+								msg = new RequestCharacterNameCreatable();
+								break;*/
 							default:
 								printDebugDoubleOpcode(opcode, id2, buf, state, client);
 						}

+ 6 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/CharacterSelect.java

@@ -69,6 +69,12 @@ public class CharacterSelect extends L2GameClientPacket
 		if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterSelect"))
 			return;
 		
+		if (Config.SECOND_AUTH_ENABLED && !getClient().getSecondaryAuth().isAuthed())
+		{
+			getClient().getSecondaryAuth().openDialog();
+			return;
+		}
+		
 		// we should always be abble to acquire the lock
 		// but if we cant lock then nothing should be done (ie repeated packet)
 		if (this.getClient().getActiveCharLock().tryLock())

+ 56 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEx2ndPasswordCheck.java

@@ -0,0 +1,56 @@
+/*
+ * 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.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordCheck;
+
+/**
+ * Format: (ch)
+ * 
+ * @author mrTJO
+ */
+public class RequestEx2ndPasswordCheck extends L2GameClientPacket
+{
+	private static final String _C__D0_AD_REQUESTEX2NDPASSWORDCHECK = "[C] D0:AD RequestEx2ndPasswordCheck";
+	//private static Logger _log = Logger.getLogger(RequestEx2ndPasswordCheck.class.getName());
+	
+	@Override
+	protected void readImpl()
+	{
+		
+	}
+	
+	@Override
+	protected void runImpl()
+	{
+		if (!Config.SECOND_AUTH_ENABLED || getClient().getSecondaryAuth().isAuthed())
+		{
+			sendPacket(new Ex2ndPasswordCheck(Ex2ndPasswordCheck.PASSWORD_OK));
+			return;
+		}
+		
+		getClient().getSecondaryAuth().openDialog();
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _C__D0_AD_REQUESTEX2NDPASSWORDCHECK;
+	}
+}

+ 71 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEx2ndPasswordReq.java

@@ -0,0 +1,71 @@
+/*
+ * 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.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordAck;
+import com.l2jserver.gameserver.security.SecondaryPasswordAuth;
+
+/**
+ * (ch)cS{S}
+ * c: change pass?
+ * S: current password
+ * S: new password
+ * 
+ * @author mrTJO
+ */
+public class RequestEx2ndPasswordReq extends L2GameClientPacket
+{
+	private static final String _C__D0_AF_REQUESTEX2NDPASSWORDREQ = "[C] D0:AF RequestEx2ndPasswordReq";
+	//private static Logger _log = Logger.getLogger(RequestEx2ndPasswordReq.class.getName());
+	int _changePass;
+	String _password, _newPassword;
+	
+	@Override
+	protected void readImpl()
+	{
+		_changePass = readC();
+		_password = readS();
+		if (_changePass == 2)
+			_newPassword = readS();
+	}
+	
+	@Override
+	protected void runImpl()
+	{
+		if (!Config.SECOND_AUTH_ENABLED)
+			return;
+		
+		SecondaryPasswordAuth spa = getClient().getSecondaryAuth();
+		boolean exVal = false;
+		
+		if (_changePass == 0 && !spa.passwordExist())
+			exVal = spa.savePassword(_password);
+		else if (_changePass == 2 && spa.passwordExist())
+			exVal = spa.changePassword(_password, _newPassword);
+		
+		if (exVal)
+			getClient().sendPacket(new Ex2ndPasswordAck(Ex2ndPasswordAck.SUCCESS));
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _C__D0_AF_REQUESTEX2NDPASSWORDREQ;
+	}
+}

+ 55 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEx2ndPasswordVerify.java

@@ -0,0 +1,55 @@
+/*
+ * 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.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.Config;
+
+/**
+ * Format: (ch)S
+ * S: numerical password
+ * 
+ * @author mrTJO
+ */
+public class RequestEx2ndPasswordVerify extends L2GameClientPacket
+{
+	private static final String _C__D0_AE_REQUESTEX2NDPASSWORDVERIFY = "[C] D0:AE RequestEx2ndPasswordVerify";
+	
+	//private static Logger _log = Logger.getLogger(RequestEx2ndPasswordVerify.class.getName());
+	String _password;
+	
+	@Override
+	protected void readImpl()
+	{
+		_password = readS();
+	}
+	
+	@Override
+	protected void runImpl()
+	{
+		if (!Config.SECOND_AUTH_ENABLED)
+			return;
+		
+		getClient().getSecondaryAuth().checkPassword(_password, false);
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _C__D0_AE_REQUESTEX2NDPASSWORDVERIFY;
+	}
+}

+ 48 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/gameserverpackets/SendMail.java

@@ -0,0 +1,48 @@
+/*
+ * 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.l2jserver.gameserver.network.gameserverpackets;
+
+import java.io.IOException;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class SendMail extends BaseSendablePacket
+{	
+	public SendMail(String accountName, String mailId, String... args)
+	{
+		writeC(0x09);
+		writeS(accountName);
+		writeS(mailId);
+		writeC(args.length);
+		for (int i = 0; i < args.length; i++)
+		{
+			writeS(args[i]);
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.util.network.BaseSendablePacket#getContent()
+	 */
+	@Override
+	public byte[] getContent() throws IOException
+	{
+		return getBytes();
+	}
+	
+}

+ 56 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/gameserverpackets/TempBan.java

@@ -0,0 +1,56 @@
+/*
+ * 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.l2jserver.gameserver.network.gameserverpackets;
+
+import java.io.IOException;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class TempBan extends BaseSendablePacket
+{	
+	public TempBan(String accountName, String ip, long time, String reason)
+	{
+		writeC(0x0A);
+		writeS(accountName);
+		writeS(ip);
+		writeQ(System.currentTimeMillis()+(time*60000));
+		if (reason != null)
+		{
+			writeC(0x01);
+			writeS(reason);
+		}
+		else
+			writeC(0x00);
+	}
+	
+	public TempBan(String accountName, String ip, long time)
+	{
+		this(accountName, ip, time, null);
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.util.network.BaseSendablePacket#getContent()
+	 */
+	@Override
+	public byte[] getContent() throws IOException
+	{
+		return getBytes();
+	}
+	
+}

+ 54 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/Ex2ndPasswordAck.java

@@ -0,0 +1,54 @@
+/*
+ * 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.l2jserver.gameserver.network.serverpackets;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class Ex2ndPasswordAck extends L2GameServerPacket
+{
+	
+	private static final String _S__FE_10B_EX2NDPASSWORDACKPACKET = "[S] FE:10B Ex2NDPasswordAckPacket";
+	int _response;
+	
+	public static int SUCCESS = 0x00;
+	public static int WRONG_PATTERN = 0x01;
+	
+	public Ex2ndPasswordAck(int response)
+	{
+		_response = response;
+	}
+	
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xFE);
+		//writeH(0x109);
+		writeH(0xe7);
+		writeC(0x00);
+		if (_response == WRONG_PATTERN)
+			writeD(0x01);
+		else
+			writeD(0x00);
+		writeD(0x00);
+	}
+	
+	@Override
+	public String getType()
+	{
+		return _S__FE_10B_EX2NDPASSWORDACKPACKET;
+	}
+}

+ 54 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/Ex2ndPasswordCheck.java

@@ -0,0 +1,54 @@
+/*
+ * 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.l2jserver.gameserver.network.serverpackets;
+
+/**
+ * Format (ch)dd
+ * d: window type
+ * d: ban user (1)
+ * 
+ * @author mrTJO
+ */
+public class Ex2ndPasswordCheck extends L2GameServerPacket
+{
+	private static final String _S__FE_109_EX2NDPASSWORDCHECKPACKET = "[S] FE:109 Ex2NDPasswordCheckPacket";
+	
+	public static final int PASSWORD_NEW = 0x00;
+	public static final int PASSWORD_PROMPT = 0x01;
+	public static final int PASSWORD_OK = 0x02;
+	
+	int _windowType;
+	
+	public Ex2ndPasswordCheck(int windowType)
+	{
+		_windowType = windowType;
+	}
+	
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xFE);
+		//writeH(0x109);
+		writeH(0xe5);
+		writeD(_windowType);
+		writeD(0x00);
+	}
+	
+	@Override
+	public String getType()
+	{
+		return _S__FE_109_EX2NDPASSWORDCHECKPACKET;
+	}
+}

+ 52 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/Ex2ndPasswordVerify.java

@@ -0,0 +1,52 @@
+/*
+ * 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.l2jserver.gameserver.network.serverpackets;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class Ex2ndPasswordVerify extends L2GameServerPacket
+{
+	private static final String _S__FE_10A_EX2NDPASSWORDVERIFYPACKET = "[S] FE:10A Ex2NDPasswordVerifyPacket";
+	
+	public static final int PASSWORD_OK = 0x00;
+	public static final int PASSWORD_WRONG = 0x01;
+	public static final int PASSWORD_BAN = 0x02;
+	
+	int _wrongTentatives, _mode;
+	
+	public Ex2ndPasswordVerify(int mode, int wrongTentatives)
+	{
+		_mode = mode;
+		_wrongTentatives = wrongTentatives;
+	}
+	
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xFE);
+		//writeH(0x109);
+		writeH(0xe6);
+		writeD(_mode);
+		writeD(_wrongTentatives);
+	}
+	
+	@Override
+	public String getType()
+	{
+		return _S__FE_10A_EX2NDPASSWORDVERIFYPACKET;
+	}
+}

+ 327 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/security/SecondaryPasswordAuth.java

@@ -0,0 +1,327 @@
+/*
+ * 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.l2jserver.gameserver.security;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.l2jserver.Base64;
+import com.l2jserver.Config;
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.LoginServerThread;
+import com.l2jserver.gameserver.network.L2GameClient;
+import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordAck;
+import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordCheck;
+import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordVerify;
+import com.l2jserver.gameserver.util.Util;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class SecondaryPasswordAuth
+{
+	private final Logger _log = Logger.getLogger(SecondaryPasswordAuth.class.getName());
+	private final L2GameClient _activeClient;
+	
+	private String _password;
+	private int _wrongAttempts;
+	private boolean _authed;
+	
+	private static final String VAR_PWD = "secauth_pwd";
+	private static final String VAR_WTE = "secauth_wte";
+	
+	private static final String SELECT_PASSWORD = "SELECT var, value FROM account_gsdata WHERE account_name=? AND var LIKE 'secauth_%'";
+	private static final String INSERT_PASSWORD = "INSERT INTO account_gsdata VALUES (?, ?, ?)";
+	private static final String UPDATE_PASSWORD = "UPDATE account_gsdata SET value=? WHERE account_name=? AND var=?";
+	
+	private static final String INSERT_ATTEMPT = "INSERT INTO account_gsdata VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value=?";
+	
+	/**
+	 * 
+	 */
+	public SecondaryPasswordAuth(L2GameClient activeClient)
+	{
+		_activeClient = activeClient;
+		_password = null;
+		_wrongAttempts = 0;
+		_authed = false;
+		loadPassword();
+	}
+	
+	private void loadPassword()
+	{
+		String var, value = null;
+		
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(SELECT_PASSWORD);
+			statement.setString(1, _activeClient.getAccountName());
+			ResultSet rs = statement.executeQuery();
+			while (rs.next())
+			{
+				var = rs.getString("var");
+				value = rs.getString("value");
+				
+				if (var.equals(VAR_PWD))
+				{
+					_password = value;
+				}
+				else if (var.equals(VAR_WTE))
+				{
+					_wrongAttempts = Integer.parseInt(value);
+				}
+			}
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Error while reading password.", e);
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+	}
+	
+	public boolean savePassword(String password)
+	{
+		if (passwordExist())
+		{
+			_log.warning("[SecondaryPasswordAuth]"+_activeClient.getAccountName()+" forced savePassword");
+			_activeClient.closeNow();
+			return false;
+		}
+		
+		if (!validatePassword(password))
+		{
+			_activeClient.sendPacket(new Ex2ndPasswordAck(Ex2ndPasswordAck.WRONG_PATTERN));
+			return false;
+		}
+		
+		password = cryptPassword(password);
+		
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(INSERT_PASSWORD);
+			statement.setString(1, _activeClient.getAccountName());
+			statement.setString(2, VAR_PWD);
+			statement.setString(3, password);
+			statement.execute();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Error while writing password.", e);
+			return false;
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+		_password = password;
+		return true;
+	}
+	
+	public boolean insertWrongAttempt(int attempts)
+	{
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(INSERT_ATTEMPT);
+			statement.setString(1, _activeClient.getAccountName());
+			statement.setString(2, VAR_WTE);
+			statement.setString(3, Integer.toString(attempts));
+			statement.setString(4, Integer.toString(attempts));
+			statement.execute();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Error while writing wrong attempts.", e);
+			return false;
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+		return true;
+	}
+	
+	public boolean changePassword(String oldPassword, String newPassword)
+	{
+		if (!passwordExist())
+		{
+			_log.warning("[SecondaryPasswordAuth]"+_activeClient.getAccountName()+" forced changePassword");
+			_activeClient.closeNow();
+			return false;
+		}
+		
+		if (!checkPassword(oldPassword, true))
+			return false;
+		
+		if (!validatePassword(newPassword))
+		{
+			_activeClient.sendPacket(new Ex2ndPasswordAck(Ex2ndPasswordAck.WRONG_PATTERN));
+			return false;
+		}
+		
+		newPassword = cryptPassword(newPassword);
+		
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(UPDATE_PASSWORD);
+			statement.setString(1, newPassword);
+			statement.setString(2, _activeClient.getAccountName());
+			statement.setString(3, VAR_PWD);
+			statement.execute();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Error while reading password.", e);
+			return false;
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+		_password = newPassword;
+		_authed = false;
+		return true;
+	}
+	
+	public boolean checkPassword(String password, boolean skipAuth)
+	{
+		password = cryptPassword(password);
+		
+		if (!password.equals(_password))
+		{
+			_wrongAttempts++;
+			if (_wrongAttempts < Config.SECOND_AUTH_MAX_ATTEMPTS)
+			{
+				_activeClient.sendPacket(new Ex2ndPasswordVerify(Ex2ndPasswordVerify.PASSWORD_WRONG, _wrongAttempts));
+				insertWrongAttempt(_wrongAttempts);
+				return false;
+			}
+			else
+			{
+				LoginServerThread.getInstance().sendTempBan(_activeClient.getAccountName(), _activeClient.getConnectionAddress().getHostAddress(), Config.SECOND_AUTH_BAN_TIME);
+				LoginServerThread.getInstance().sendMail(_activeClient.getAccountName(), "SATempBan", 
+						_activeClient.getConnectionAddress().getHostAddress(), Integer.toString(Config.SECOND_AUTH_MAX_ATTEMPTS),
+						Long.toString(Config.SECOND_AUTH_BAN_TIME), Config.SECOND_AUTH_REC_LINK);
+				_log.warning(_activeClient.getAccountName()+" - ("+
+						_activeClient.getConnectionAddress().getHostAddress()+") has inputted the wrong password "+
+						_wrongAttempts+" times in row.");
+				insertWrongAttempt(0);
+				_activeClient.close(new Ex2ndPasswordVerify(Ex2ndPasswordVerify.PASSWORD_BAN, Config.SECOND_AUTH_MAX_ATTEMPTS));
+				return false;
+			}
+		}
+		if (!skipAuth)
+		{
+			_authed = true;
+			_activeClient.sendPacket(new Ex2ndPasswordVerify(Ex2ndPasswordVerify.PASSWORD_OK, _wrongAttempts));
+		}
+		insertWrongAttempt(0);
+		return true;
+	}
+	
+	public boolean passwordExist()
+	{
+		return _password == null ? false : true;
+	}
+	
+	public void openDialog()
+	{
+		if (passwordExist())
+			_activeClient.sendPacket(new Ex2ndPasswordCheck(Ex2ndPasswordCheck.PASSWORD_PROMPT));
+		else
+			_activeClient.sendPacket(new Ex2ndPasswordCheck(Ex2ndPasswordCheck.PASSWORD_NEW));
+	}
+	
+	public boolean isAuthed()
+	{
+		return _authed;
+	}
+	
+	private String cryptPassword(String password)
+	{
+		try
+		{
+			MessageDigest md = MessageDigest.getInstance("SHA");
+			byte[] raw = password.getBytes("UTF-8");
+			byte[] hash = md.digest(raw);
+			return Base64.encodeBytes(hash);
+		}
+		catch (NoSuchAlgorithmException e)
+		{
+			_log.severe("[SecondaryPasswordAuth]Unsupported Algorythm");
+		}
+		catch (UnsupportedEncodingException e)
+		{
+			_log.severe("[SecondaryPasswordAuth]Unsupported Encoding");
+		}
+		return null;
+	}
+	
+	private boolean validatePassword(String password)
+	{
+		if (!Util.isDigit(password))
+			return false;
+		
+		if (password.length() < 6 || password.length() > 8)
+			return false;
+		
+		for (int i = 0; i < password.length()-1; i++)
+		{
+			char curCh = password.charAt(i);
+			char nxtCh = password.charAt(i+1);
+			
+			if (curCh+1 == nxtCh)
+				return false;
+			else if (curCh-1 == nxtCh)
+				return false;
+			else if (curCh == nxtCh)
+				return false;
+		}
+		
+		for (int i = 0; i < password.length()-2; i++)
+		{
+			String toChk = password.substring(i+1);
+			StringBuffer chkEr = new StringBuffer(password.substring(i, i+2));
+			
+			if (toChk.contains(chkEr))
+				return false;
+			else if (toChk.contains(chkEr.reverse()))
+				return false;
+		}
+		_wrongAttempts = 0;
+		return true;
+	}
+}

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/loginserver/GameServerTable.java

@@ -43,7 +43,7 @@ import javolution.xml.stream.XMLStreamException;
 import javolution.xml.stream.XMLStreamReaderImpl;
 
 import com.l2jserver.L2DatabaseFactory;
-import com.l2jserver.loginserver.gameserverpackets.ServerStatus;
+import com.l2jserver.loginserver.network.gameserverpackets.ServerStatus;
 import com.l2jserver.util.IPSubnet;
 import com.l2jserver.util.Rnd;
 
@@ -116,7 +116,7 @@ public class GameServerTable
 		InputStream in = null;
 		try
 		{
-			in = new FileInputStream("servername.xml");
+			in = new FileInputStream("data/servername.xml");
 			XMLStreamReaderImpl xpp = new XMLStreamReaderImpl();
 			xpp.setInput(new UTF8StreamReader().setInput(in));
 			for (int e = xpp.getEventType(); e != XMLStreamConstants.END_DOCUMENT; e = xpp.next())

+ 73 - 461
L2J_Server_BETA/java/com/l2jserver/loginserver/GameServerThread.java

@@ -22,8 +22,6 @@ import java.net.Socket;
 import java.security.KeyPair;
 import java.security.interfaces.RSAPrivateKey;
 import java.security.interfaces.RSAPublicKey;
-import java.util.Arrays;
-import java.util.List;
 import java.util.Set;
 import java.util.logging.Logger;
 
@@ -31,21 +29,12 @@ import javolution.util.FastSet;
 
 import com.l2jserver.Config;
 import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
-import com.l2jserver.loginserver.gameserverpackets.BlowFishKey;
-import com.l2jserver.loginserver.gameserverpackets.ChangeAccessLevel;
-import com.l2jserver.loginserver.gameserverpackets.GameServerAuth;
-import com.l2jserver.loginserver.gameserverpackets.PlayerAuthRequest;
-import com.l2jserver.loginserver.gameserverpackets.PlayerInGame;
-import com.l2jserver.loginserver.gameserverpackets.PlayerLogout;
-import com.l2jserver.loginserver.gameserverpackets.PlayerTracert;
-import com.l2jserver.loginserver.gameserverpackets.ReplyCharacters;
-import com.l2jserver.loginserver.gameserverpackets.ServerStatus;
-import com.l2jserver.loginserver.loginserverpackets.AuthResponse;
-import com.l2jserver.loginserver.loginserverpackets.InitLS;
-import com.l2jserver.loginserver.loginserverpackets.KickPlayer;
-import com.l2jserver.loginserver.loginserverpackets.LoginServerFail;
-import com.l2jserver.loginserver.loginserverpackets.PlayerAuthResponse;
-import com.l2jserver.loginserver.loginserverpackets.RequestCharacters;
+import com.l2jserver.loginserver.network.L2JGameServerPacketHandler;
+import com.l2jserver.loginserver.network.L2JGameServerPacketHandler.GameServerState;
+import com.l2jserver.loginserver.network.loginserverpackets.InitLS;
+import com.l2jserver.loginserver.network.loginserverpackets.KickPlayer;
+import com.l2jserver.loginserver.network.loginserverpackets.LoginServerFail;
+import com.l2jserver.loginserver.network.loginserverpackets.RequestCharacters;
 import com.l2jserver.util.Util;
 import com.l2jserver.util.crypt.NewCrypt;
 import com.l2jserver.util.network.BaseSendablePacket;
@@ -59,20 +48,20 @@ import com.l2jserver.util.network.BaseSendablePacket;
 public class GameServerThread extends Thread
 {
 	protected static final Logger _log = Logger.getLogger(GameServerThread.class.getName());
-	private Socket _connection;
+	private final Socket _connection;
 	private InputStream _in;
 	private OutputStream _out;
-	private RSAPublicKey _publicKey;
-	private RSAPrivateKey _privateKey;
+	private final RSAPublicKey _publicKey;
+	private final RSAPrivateKey _privateKey;
 	private NewCrypt _blowfish;
-	private byte[] _blowfishKey;
+	private GameServerState _loginConnectionState = GameServerState.CONNECTED;
 	
-	private String _connectionIp;
+	private final String _connectionIp;
 	
 	private GameServerInfo _gsi;
 	
 	/** Authed Clients on a GameServer*/
-	private Set<String> _accountsOnGameServer = new FastSet<String>();
+	private final Set<String> _accountsOnGameServer = new FastSet<String>();
 	
 	private String _connectionIPAddress;
 	
@@ -141,41 +130,7 @@ public class GameServerThread extends Thread
 					_log.warning("[C]\n"+Util.printData(data));
 				}
 				
-				int packetType = data[0] & 0xff;
-				switch (packetType)
-				{
-					case 0x00:
-						onReceiveBlowfishKey(data);
-						break;
-					case 0x01:
-						onGameServerAuth(data);
-						break;
-					case 0x02:
-						onReceivePlayerInGame(data);
-						break;
-					case 0x03:
-						onReceivePlayerLogOut(data);
-						break;
-					case 0x04:
-						onReceiveChangeAccessLevel(data);
-						break;
-					case 0x05:
-						onReceivePlayerAuthRequest(data);
-						break;
-					case 0x06:
-						onReceiveServerStatus(data);
-						break;
-					case 0x07:
-						onReceivePlayerTracert(data);
-						break;
-					case 0x08:
-						onReceivePlayerOnServer(data);
-						break;
-					default:
-						_log.warning("Unknown Opcode ("+Integer.toHexString(packetType).toUpperCase()+") from GameServer, closing connection.");
-						forceClose(LoginServerFail.NOT_AUTHED);
-				}
-				
+				L2JGameServerPacketHandler.handlePacket(data, this);
 			}
 		}
 		catch (IOException e)
@@ -197,265 +152,6 @@ public class GameServerThread extends Thread
 		}
 	}
 	
-	private void onReceiveBlowfishKey(byte[] data)
-	{
-		/*if (_blowfish == null)
-		{*/
-		BlowFishKey bfk = new BlowFishKey(data,_privateKey);
-		_blowfishKey = bfk.getKey();
-		_blowfish = new NewCrypt(_blowfishKey);
-		if (Config.DEBUG)
-		{
-			_log.info("New BlowFish key received, Blowfih Engine initialized:");
-		}
-		/*}
-		else
-		{
-			_log.warning("GameServer attempted to re-initialize the blowfish key.");
-			// TODO get a better reason
-			this.forceClose(LoginServerFail.NOT_AUTHED);
-		}*/
-	}
-	
-	private void onGameServerAuth(byte[] data) throws IOException
-	{
-		GameServerAuth gsa = new GameServerAuth(data);
-		if (Config.DEBUG)
-		{
-			_log.info("Auth request received");
-		}
-		handleRegProcess(gsa);
-		if (isAuthed())
-		{
-			AuthResponse ar = new AuthResponse(getGameServerInfo().getId());
-			sendPacket(ar);
-			if (Config.DEBUG)
-			{
-				_log.info("Authed: id: "+getGameServerInfo().getId());
-			}
-			broadcastToTelnet("GameServer ["+getServerId()+"] "+GameServerTable.getInstance().getServerNameById(getServerId())+" is connected");
-		}
-	}
-	
-	private void onReceivePlayerInGame(byte[] data)
-	{
-		if (isAuthed())
-		{
-			PlayerInGame pig = new PlayerInGame(data);
-			List<String> newAccounts = pig.getAccounts();
-			for (String account : newAccounts)
-			{
-				_accountsOnGameServer.add(account);
-				if (Config.DEBUG)
-				{
-					_log.info("Account "+account+" logged in GameServer: ["+getServerId()+"] "+GameServerTable.getInstance().getServerNameById(getServerId()));
-				}
-				
-				broadcastToTelnet("Account "+account+" logged in GameServer "+getServerId());
-			}
-			
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void onReceivePlayerLogOut(byte[] data)
-	{
-		if (isAuthed())
-		{
-			PlayerLogout plo = new PlayerLogout(data);
-			_accountsOnGameServer.remove(plo.getAccount());
-			if (Config.DEBUG)
-			{
-				_log.info("Player "+plo.getAccount()+" logged out from gameserver ["+getServerId()+"] "+GameServerTable.getInstance().getServerNameById(getServerId()));
-			}
-			
-			broadcastToTelnet("Player "+plo.getAccount()+" disconnected from GameServer "+getServerId());
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void onReceiveChangeAccessLevel(byte[] data)
-	{
-		if (isAuthed())
-		{
-			ChangeAccessLevel cal = new ChangeAccessLevel(data);
-			LoginController.getInstance().setAccountAccessLevel(cal.getAccount(),cal.getLevel());
-			_log.info("Changed "+cal.getAccount()+" access level to "+cal.getLevel());
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void onReceivePlayerAuthRequest(byte[] data) throws IOException
-	{
-		if (isAuthed())
-		{
-			PlayerAuthRequest par = new PlayerAuthRequest(data);
-			PlayerAuthResponse authResponse;
-			if (Config.DEBUG)
-			{
-				_log.info("auth request received for Player "+par.getAccount());
-			}
-			SessionKey key = LoginController.getInstance().getKeyForAccount(par.getAccount());
-			if (key != null && key.equals(par.getKey()))
-			{
-				if (Config.DEBUG)
-				{
-					_log.info("auth request: OK");
-				}
-				LoginController.getInstance().removeAuthedLoginClient(par.getAccount());
-				authResponse = new PlayerAuthResponse(par.getAccount(), true);
-			}
-			else
-			{
-				if (Config.DEBUG)
-				{
-					_log.info("auth request: NO");
-					_log.info("session key from self: "+key);
-					_log.info("session key sent: "+par.getKey());
-				}
-				authResponse = new PlayerAuthResponse(par.getAccount(), false);
-			}
-			sendPacket(authResponse);
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void onReceiveServerStatus(byte[] data)
-	{
-		if (isAuthed())
-		{
-			if (Config.DEBUG)
-			{
-				_log.info("ServerStatus received");
-			}
-			new ServerStatus(data,getServerId()); //will do the actions by itself
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void onReceivePlayerTracert(byte[] data)
-	{
-		if (isAuthed())
-		{
-			PlayerTracert plt = new PlayerTracert(data);
-			LoginController.getInstance().setAccountLastTracert(plt.getAccount(),
-					plt.getPcIp(), plt.getFirstHop(), plt.getSecondHop(),
-					plt.getThirdHop(), plt.getFourthHop());
-			if (Config.DEBUG)
-			{
-				_log.info("Saved "+plt.getAccount()+" last tracert");
-			}
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void onReceivePlayerOnServer(byte[] data)
-	{
-		if (isAuthed())
-		{
-			ReplyCharacters rec = new ReplyCharacters(data);
-			LoginController.getInstance().setCharactersOnServer(rec.getAccountName(),
-					rec.getCharsOnServer(), rec.getTimeToDelForChars(), getServerId());
-		}
-		else
-		{
-			forceClose(LoginServerFail.NOT_AUTHED);
-		}
-	}
-	
-	private void handleRegProcess(GameServerAuth gameServerAuth)
-	{
-		GameServerTable gameServerTable = GameServerTable.getInstance();
-		
-		int id = gameServerAuth.getDesiredID();
-		byte[] hexId = gameServerAuth.getHexID();
-		
-		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())
-					{
-						forceClose(LoginServerFail.REASON_ALREADY_LOGGED8IN);
-					}
-					else
-					{
-						attachGameServerInfo(gsi, gameServerAuth);
-					}
-				}
-			}
-			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 && gameServerAuth.acceptAlternateID())
-				{
-					gsi = new GameServerInfo(id, hexId, this);
-					if (gameServerTable.registerWithFirstAvaliableId(gsi))
-					{
-						attachGameServerInfo(gsi, gameServerAuth);
-						gameServerTable.registerServerOnDB(gsi);
-					}
-					else
-					{
-						forceClose(LoginServerFail.REASON_NO_FREE_ID);
-					}
-				}
-				else
-				{
-					// server id is already taken, and we cant get a new one for you
-					forceClose(LoginServerFail.REASON_WRONG_HEXID);
-				}
-			}
-		}
-		else
-		{
-			// can we register on this id?
-			if (Config.ACCEPT_NEW_GAMESERVER)
-			{
-				gsi = new GameServerInfo(id, hexId, this);
-				if (gameServerTable.register(id, gsi))
-				{
-					attachGameServerInfo(gsi, gameServerAuth);
-					gameServerTable.registerServerOnDB(gsi);
-				}
-				else
-				{
-					// some one took this ID meanwhile
-					forceClose(LoginServerFail.REASON_ID_RESERVED);
-				}
-			}
-			else
-			{
-				forceClose(LoginServerFail.REASON_WRONG_HEXID);
-			}
-		}
-	}
-	
 	public boolean hasAccountOnGameServer(String account)
 	{
 		return _accountsOnGameServer.contains(account);
@@ -473,27 +169,19 @@ public class GameServerThread extends Thread
 	 * @param gsi The GameServerInfo to be attached.
 	 * @param gameServerAuth The server info.
 	 */
-	private void attachGameServerInfo(GameServerInfo gsi, GameServerAuth gameServerAuth)
+	public void attachGameServerInfo(GameServerInfo gsi, int port, String[] hosts, int maxPlayers)
 	{
 		setGameServerInfo(gsi);
 		gsi.setGameServerThread(this);
-		gsi.setPort(gameServerAuth.getPort());
-		setGameHosts(gameServerAuth.getHosts());
-		gsi.setMaxPlayers(gameServerAuth.getMaxPlayers());
+		gsi.setPort(port);
+		setGameHosts(hosts);
+		gsi.setMaxPlayers(maxPlayers);
 		gsi.setAuthed(true);
 	}
 	
-	private void forceClose(int reason)
+	public void forceClose(int reason)
 	{
-		LoginServerFail lsf = new LoginServerFail(reason);
-		try
-		{
-			sendPacket(lsf);
-		}
-		catch (IOException e)
-		{
-			_log.finer("GameServerThread: Failed kicking banned server. Reason: "+e.getMessage());
-		}
+		sendPacket(new LoginServerFail(reason));
 		
 		try
 		{
@@ -505,103 +193,6 @@ public class GameServerThread extends Thread
 		}
 	}
 	
-	/*private void handleRegisterationProcess(GameServerAuth gameServerauth)
-	{
-		try
-		{
-			GameServerTable gsTableInstance = GameServerTable.getInstance();
-			if (gsTableInstance.isARegisteredServer(gameServerauth.getHexID()))
-			{
-				if (Config.DEBUG)
-				{
-					_log.info("Valid HexID");
-				}
-				_server_id = gsTableInstance.getServerIDforHex(gameServerauth.getHexID());
-				if (gsTableInstance.isServerAuthed(_server_id))
-				{
-					LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_ALREADY_LOGGED8IN);
-					sendPacket(lsf);
-					_connection.close();
-					return;
-				}
-				_gamePort = gameServerauth.getPort();
-				setGameHosts(gameServerauth.getExternalHost(), gameServerauth.getInternalHost());
-				_max_players = gameServerauth.getMaxPlayers();
-				_hexID = gameServerauth.getHexID();
-				//gsTableInstance.addServer(this);
-			}
-			else if (Config.ACCEPT_NEW_GAMESERVER)
-			{
-				if (Config.DEBUG)
-				{
-					_log.info("New HexID");
-				}
-				if(!gameServerauth.acceptAlternateID())
-				{
-					if(gsTableInstance.isIDfree(gameServerauth.getDesiredID()))
-					{
-						if (Config.DEBUG)_log.info("Desired ID is Valid");
-						_server_id = gameServerauth.getDesiredID();
-						_gamePort = gameServerauth.getPort();
-						setGameHosts(gameServerauth.getExternalHost(), gameServerauth.getInternalHost());
-						_max_players = gameServerauth.getMaxPlayers();
-						_hexID = gameServerauth.getHexID();
-						gsTableInstance.createServer(this);
-						//gsTableInstance.addServer(this);
-					}
-					else
-					{
-						LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_ID_RESERVED);
-						sendPacket(lsf);
-						_connection.close();
-						return;
-					}
-				}
-				else
-				{
-					int id;
-					if(!gsTableInstance.isIDfree(gameServerauth.getDesiredID()))
-					{
-						id = gsTableInstance.findFreeID();
-						if (Config.DEBUG)_log.info("Affected New ID:"+id);
-						if(id < 0)
-						{
-							LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_NO_FREE_ID);
-							sendPacket(lsf);
-							_connection.close();
-							return;
-						}
-					}
-					else
-					{
-						id = gameServerauth.getDesiredID();
-						if (Config.DEBUG)_log.info("Desired ID is Valid");
-					}
-					_server_id = id;
-					_gamePort = gameServerauth.getPort();
-					setGameHosts(gameServerauth.getExternalHost(), gameServerauth.getInternalHost());
-					_max_players = gameServerauth.getMaxPlayers();
-					_hexID = gameServerauth.getHexID();
-					gsTableInstance.createServer(this);
-					//gsTableInstance.addServer(this);
-				}
-			}
-			else
-			{
-				_log.info("Wrong HexID");
-				LoginServerFail lsf = new LoginServerFail(LoginServerFail.REASON_WRONG_HEXID);
-				sendPacket(lsf);
-				_connection.close();
-				return;
-			}
-
-		}
-		catch (IOException e)
-		{
-			_log.info("Error while registering GameServer "+GameServerTable.getInstance().serverNames.get(_server_id)+" (ID:"+_server_id+")");
-		}
-	}*/
-	
 	/**
 	 * @param ipAddress
 	 * @return
@@ -636,27 +227,34 @@ public class GameServerThread extends Thread
 	 * @param sl
 	 * @throws IOException
 	 */
-	private void sendPacket(BaseSendablePacket sl) throws IOException
+	public void sendPacket(BaseSendablePacket sl)
 	{
-		byte[] data = sl.getContent();
-		NewCrypt.appendChecksum(data);
-		if (Config.DEBUG)
+		try
 		{
-			_log.finest("[S] "+sl.getClass().getSimpleName()+":\n"+Util.printData(data));
+			byte[] data = sl.getContent();
+			NewCrypt.appendChecksum(data);
+			if (Config.DEBUG)
+			{
+				_log.finest("[S] "+sl.getClass().getSimpleName()+":\n"+Util.printData(data));
+			}
+			data = _blowfish.crypt(data);
+			
+			int len = data.length+2;
+			synchronized(_out)
+			{
+				_out.write(len & 0xff);
+				_out.write(len >> 8 &0xff);
+				_out.write(data);
+				_out.flush();
+			}
 		}
-		data = _blowfish.crypt(data);
-		
-		int len = data.length+2;
-		synchronized(_out)
+		catch (IOException e)
 		{
-			_out.write(len & 0xff);
-			_out.write(len >> 8 &0xff);
-			_out.write(data);
-			_out.flush();
+			_log.severe("IOException while sending packet "+sl.getClass().getSimpleName());
 		}
 	}
 	
-	private void broadcastToTelnet(String msg)
+	public void broadcastToTelnet(String msg)
 	{
 		if (L2LoginServer.getInstance().getStatusServer() != null)
 		{
@@ -666,28 +264,12 @@ public class GameServerThread extends Thread
 	
 	public void kickPlayer(String account)
 	{
-		KickPlayer kp = new KickPlayer(account);
-		try
-		{
-			sendPacket(kp);
-		}
-		catch (IOException e)
-		{
-			e.printStackTrace();
-		}
+		sendPacket(new KickPlayer(account));
 	}
 	
 	public void requestCharacters(String account)
 	{
-		RequestCharacters rc = new RequestCharacters(account);
-		try
-		{
-			sendPacket(rc);
-		}
-		catch (IOException e)
-		{
-			e.printStackTrace();
-		}
+		sendPacket(new RequestCharacters(account));
 	}
 	
 	/**
@@ -742,7 +324,7 @@ public class GameServerThread extends Thread
 		return _connectionIPAddress;
 	}
 	
-	private int getServerId()
+	public int getServerId()
 	{
 		if (getGameServerInfo() != null)
 		{
@@ -750,4 +332,34 @@ public class GameServerThread extends Thread
 		}
 		return -1;
 	}
+	
+	public RSAPrivateKey getPrivateKey()
+	{
+		return _privateKey;
+	}
+	
+	public void SetBlowFish(NewCrypt blowfish)
+	{
+		_blowfish = blowfish;
+	}
+	
+	public void addAccountOnGameServer(String account)
+	{
+		_accountsOnGameServer.add(account);
+	}
+	
+	public void removeAccountOnGameServer(String account)
+	{
+		_accountsOnGameServer.remove(account);
+	}
+	
+	public GameServerState getLoginConnectionState()
+	{
+		return _loginConnectionState;
+	}
+	
+	public void setLoginConnectionState(GameServerState state)
+	{
+		_loginConnectionState = state;
+	}
 }

+ 11 - 2
L2J_Server_BETA/java/com/l2jserver/loginserver/L2LoginServer.java

@@ -35,6 +35,9 @@ import org.mmocore.network.SelectorThread;
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.Server;
+import com.l2jserver.loginserver.mail.MailSystem;
+import com.l2jserver.loginserver.network.L2LoginClient;
+import com.l2jserver.loginserver.network.L2LoginPacketHandler;
 import com.l2jserver.status.Status;
 
 /**
@@ -43,10 +46,10 @@ import com.l2jserver.status.Status;
  */
 public class L2LoginServer
 {
-	public static final int PROTOCOL_REV = 0x0105;
+	public static final int PROTOCOL_REV = 0x0106;
 	
 	private static L2LoginServer _instance;
-	private Logger _log = Logger.getLogger(L2LoginServer.class.getName());
+	private final Logger _log = Logger.getLogger(L2LoginServer.class.getName());
 	private GameServerListener _gameServerListener;
 	private SelectorThread<L2LoginClient> _selectorThread;
 	private Status _statusServer;
@@ -142,6 +145,11 @@ public class L2LoginServer
 		
 		loadBanFile();
 		
+		if (Config.EMAIL_SYS_ENABLED)
+		{
+			MailSystem.getInstance();
+		}
+		
 		InetAddress bindAddress = null;
 		if (!Config.LOGIN_BIND_ADDRESS.equals("*"))
 		{
@@ -212,6 +220,7 @@ public class L2LoginServer
 			System.exit(1);
 		}
 		_selectorThread.start();
+		
 		_log.info("Login Server ready on " + (bindAddress == null ? "*" : bindAddress.getHostAddress()) + ":" + Config.PORT_LOGIN);
 	}
 	

+ 23 - 13
L2J_Server_BETA/java/com/l2jserver/loginserver/LoginController.java

@@ -37,8 +37,9 @@ import com.l2jserver.Base64;
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
-import com.l2jserver.loginserver.gameserverpackets.ServerStatus;
-import com.l2jserver.loginserver.serverpackets.LoginFail.LoginFailReason;
+import com.l2jserver.loginserver.network.L2LoginClient;
+import com.l2jserver.loginserver.network.gameserverpackets.ServerStatus;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
 import com.l2jserver.util.Rnd;
 import com.l2jserver.util.crypt.ScrambledKeyPair;
 import com.l2jserver.util.lib.Log;
@@ -60,17 +61,23 @@ public class LoginController
 	/** Authed Clients on LoginServer*/
 	protected FastMap<String, L2LoginClient> _loginServerClients = new FastMap<String, L2LoginClient>().shared();
 	
-	private Map<String, BanInfo> _bannedIps = new FastMap<String, BanInfo>().shared();
+	private final Map<String, BanInfo> _bannedIps = new FastMap<String, BanInfo>().shared();
 	
-	private Map<InetAddress, FailedLoginAttempt> _hackProtection;
+	private final Map<InetAddress, FailedLoginAttempt> _hackProtection;
 	
 	protected ScrambledKeyPair[] _keyPairs;
 	
-	private Thread _purge;
+	private final Thread _purge;
 	
 	protected byte[][] _blowfishKeys;
 	private static final int BLOWFISH_KEYS = 20;
 	
+	private static final String ACCESS_LEVEL_SELECT = "SELECT IF(? > value OR value IS NULL, accessLevel, -100) AS accessLevel " +
+			"FROM accounts LEFT JOIN (account_data) ON (account_data.account_name=accounts.login AND account_data.var=\"ban_temp\") WHERE login=?";
+	
+	private static final String USER_INFO_SELECT = "SELECT password, IF(? > value OR value IS NULL, accessLevel, -100) AS accessLevel, lastServer, userIp " +
+			"FROM accounts LEFT JOIN (account_data) ON (account_data.account_name=accounts.login AND account_data.var=\"ban_temp\") WHERE login=?";
+	
 	public static void load() throws GeneralSecurityException
 	{
 		synchronized (LoginController.class)
@@ -513,8 +520,9 @@ public class LoginController
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT accessLevel FROM accounts WHERE login=?");
-			statement.setString(1, user);
+			statement = con.prepareStatement(ACCESS_LEVEL_SELECT);
+			statement.setString(1, Long.toString(System.currentTimeMillis()));
+			statement.setString(2, user);
 			ResultSet rset = statement.executeQuery();
 			if (rset.next())
 			{
@@ -585,8 +593,9 @@ public class LoginController
 			String userIP = null;
 			
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT password, accessLevel, lastServer, userIP FROM accounts WHERE login=?");
-			statement.setString(1, user);
+			PreparedStatement statement = con.prepareStatement(USER_INFO_SELECT);
+			statement.setString(1, Long.toString(System.currentTimeMillis()));
+			statement.setString(2, user);
 			ResultSet rset = statement.executeQuery();
 			if (rset.next())
 			{
@@ -771,8 +780,9 @@ public class LoginController
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT accessLevel FROM accounts WHERE login=?");
-			statement.setString(1, user);
+			PreparedStatement statement = con.prepareStatement(ACCESS_LEVEL_SELECT);
+			statement.setString(1, Long.toString(System.currentTimeMillis()));
+			statement.setString(2, user);
 			ResultSet rset = statement.executeQuery();
 			if (rset.next())
 			{
@@ -873,9 +883,9 @@ public class LoginController
 	
 	class BanInfo
 	{
-		private InetAddress _ipAddress;
+		private final InetAddress _ipAddress;
 		// Expiration
-		private long _expiration;
+		private final long _expiration;
 		
 		public BanInfo(InetAddress ipAddress, long expiration)
 		{

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/loginserver/SelectorHelper.java

@@ -23,7 +23,8 @@ import org.mmocore.network.IMMOExecutor;
 import org.mmocore.network.MMOConnection;
 import org.mmocore.network.ReceivablePacket;
 
-import com.l2jserver.loginserver.serverpackets.Init;
+import com.l2jserver.loginserver.network.L2LoginClient;
+import com.l2jserver.loginserver.network.serverpackets.Init;
 import com.l2jserver.util.IPv4Filter;
 
 /**

+ 0 - 108
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/GameServerAuth.java

@@ -1,108 +0,0 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import java.util.logging.Logger;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-
-/**
- * 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 BaseRecievePacket
-{
-	protected static Logger _log = Logger.getLogger(GameServerAuth.class.getName());
-	private byte[] _hexId;
-	private int _desiredId;
-	private boolean _hostReserved;
-	private boolean _acceptAlternativeId;
-	private int _maxPlayers;
-	private int _port;
-	private String[] _hosts;
-	
-	/**
-	 * @param decrypt
-	 */
-	public GameServerAuth(byte[] decrypt)
-	{
-		super(decrypt);
-		_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();
-	}
-	
-	/**
-	 * @return
-	 */
-	public byte[] getHexID()
-	{
-		return _hexId;
-	}
-	
-	public boolean getHostReserved()
-	{
-		return _hostReserved;
-	}
-	
-	public int getDesiredID()
-	{
-		return _desiredId;
-	}
-	
-	public boolean acceptAlternateID()
-	{
-		return _acceptAlternativeId;
-	}
-	
-	/**
-	 * @return Returns the max players.
-	 */
-	public int getMaxPlayers()
-	{
-		return _maxPlayers;
-	}
-	
-	public String[] getHosts()
-	{
-		return _hosts;
-	}
-	
-	/**
-	 * @return Returns the port.
-	 */
-	public int getPort()
-	{
-		return _port;
-	}
-}

+ 0 - 93
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/PlayerTracert.java

@@ -1,93 +0,0 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-/**
- * @author mrTJO
- *
- */
-public class PlayerTracert extends BaseRecievePacket
-{
-	private String _account;
-	private String _pcIp;
-	private String _hop1;
-	private String _hop2;
-	private String _hop3;
-	private String _hop4;
-	
-	/**
-	 * @param decrypt
-	 */
-	public PlayerTracert(byte[] decrypt)
-	{
-		super(decrypt);
-		_account = readS();
-		_pcIp = readS();
-		_hop1 = readS();
-		_hop2 = readS();
-		_hop3 = readS();
-		_hop4 = readS();
-	}
-	
-	/**
-	 * @return Returns the account.
-	 */
-	public String getAccount()
-	{
-		return _account;
-	}
-	
-	/**
-	 * @return Returns PC IP.
-	 */
-	public String getPcIp()
-	{
-		return _pcIp;
-	}
-	
-	/**
-	 * @return Returns 1st Traceroute Hop.
-	 */
-	public String getFirstHop()
-	{
-		return _hop1;
-	}
-	
-	/**
-	 * @return Returns 2nd Traceroute Hop.
-	 */
-	public String getSecondHop()
-	{
-		return _hop2;
-	}
-	
-	/**
-	 * @return Returns 3rd Traceroute Hop.
-	 */
-	public String getThirdHop()
-	{
-		return _hop3;
-	}
-	
-	/**
-	 * @return Returns 4th Traceroute Hop.
-	 */
-	public String getFourthHop()
-	{
-		return _hop4;
-	}
-}

+ 178 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/mail/BaseMail.java

@@ -0,0 +1,178 @@
+/*
+ * 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.l2jserver.loginserver.mail;
+
+import java.io.UnsupportedEncodingException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import javax.mail.Authenticator;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import com.l2jserver.Config;
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.loginserver.mail.MailSystem.MailContent;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class BaseMail implements Runnable
+{
+	private final static Logger _log = Logger.getLogger(BaseMail.class.getName());
+	
+	private static final String QUERY_SEL_MAIL = "SELECT value FROM account_data " +
+	"WHERE account_name=? AND var='email_addr'";
+	
+	private final Properties _mailProp = new Properties();
+	private final SmtpAuthenticator _authenticator;
+	private MimeMessage _messageMime = null;
+	
+	private class SmtpAuthenticator extends Authenticator
+	{
+		private final PasswordAuthentication _auth;
+		
+		public SmtpAuthenticator()
+		{
+			_auth = new PasswordAuthentication(Config.EMAIL_SYS_USERNAME, Config.EMAIL_SYS_PASSWORD);
+		}
+		
+		@Override
+		public PasswordAuthentication getPasswordAuthentication()
+		{
+			return _auth;
+		}
+	}
+	
+	public BaseMail(String account, String mailId, String... args)
+	{
+		_mailProp.put("mail.smtp.host", Config.EMAIL_SYS_HOST);
+		_mailProp.put("mail.smtp.auth", Config.EMAIL_SYS_SMTP_AUTH);
+		_mailProp.put("mail.smtp.port", Config.EMAIL_SYS_PORT);
+		_mailProp.put("mail.smtp.socketFactory.port", Config.EMAIL_SYS_PORT);
+		_mailProp.put("mail.smtp.socketFactory.class", Config.EMAIL_SYS_FACTORY);
+		_mailProp.put("mail.smtp.socketFactory.fallback", Config.EMAIL_SYS_FACTORY_CALLBACK);
+		
+		_authenticator = Config.EMAIL_SYS_SMTP_AUTH ? new SmtpAuthenticator() : null;
+		
+		String mailAddr = getUserMail(account);
+		
+		if (mailAddr == null)
+			return;
+		
+		MailContent content = MailSystem.getInstance().getMailContent(mailId);
+		if (content == null)
+			return;
+		
+		String message = compileHtml(account, content.getText(), args);
+		
+		Session mailSession = Session.getDefaultInstance(_mailProp, _authenticator);
+		
+		try
+		{
+			_messageMime = new MimeMessage(mailSession);
+			_messageMime.setSubject(content.getSubject());
+			try
+			{
+				_messageMime.setFrom(new InternetAddress(Config.EMAIL_SYS_ADDRESS, Config.EMAIL_SERVERINFO_NAME));
+			}
+			catch (UnsupportedEncodingException e)
+			{
+				_log.warning("Sender Address not Valid!");
+			}
+			_messageMime.setContent(message, "text/html");
+			_messageMime.setRecipient(Message.RecipientType.TO, new InternetAddress(mailAddr));
+		}
+		catch (MessagingException e)
+		{
+			e.printStackTrace();
+		}
+	}
+	
+	
+	
+	private String compileHtml(String account, String html, String[] args)
+	{
+		if (args != null)
+		{
+			for (int i = 0; i < args.length; i++)
+			{
+				html = html.replace("%var"+i+"%", args[i]);
+			}
+		}
+		html = html.replace("%accountname%", account);
+		return html;
+	}
+	
+	private String getUserMail(String username)
+	{
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(QUERY_SEL_MAIL);
+			statement.setString(1, username);
+			ResultSet rset = statement.executeQuery();
+			if (rset.next())
+			{
+				String mail = rset.getString("value");
+				return mail;
+			}
+			rset.close();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.warning("Cannot select user mail: Exception");
+		}
+		finally
+		{
+			try
+			{
+				L2DatabaseFactory.close(con);
+			}
+			catch (Exception e)
+			{
+			}
+		}
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Runnable#run()
+	 */
+	@Override
+	public void run()
+	{
+		try
+		{
+			if (_messageMime != null)
+				Transport.send(_messageMime);
+		}
+		catch (MessagingException e)
+		{
+			_log.warning("Error encounterd while sending email");
+		}
+	}
+}

+ 148 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/mail/MailSystem.java

@@ -0,0 +1,148 @@
+/*
+ * 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.l2jserver.loginserver.mail;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import javolution.util.FastMap;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import com.l2jserver.Config;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class MailSystem
+{
+	private final static Logger _log = Logger.getLogger(MailSystem.class.getName());
+	private final Map<String, MailContent> _mailData = new FastMap<String, MailContent>();
+		
+	public static MailSystem getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	public MailSystem()
+	{
+		loadMails();
+	}
+	
+	public void sendMail(String account, String messageId, String... args)
+	{
+		BaseMail mail = new BaseMail(account, messageId, args);
+		mail.run();
+	}
+	
+	private void loadMails()
+	{
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		factory.setValidating(false);
+		factory.setIgnoringComments(true);
+		File file = new File("data/mail/MailList.xml");
+		Document doc = null;
+		if (file.exists())
+		{
+			try
+			{
+				doc = factory.newDocumentBuilder().parse(file);
+			}
+			catch (Exception e)
+			{
+				_log.log(Level.WARNING, "Could not parse MailList.xml file: " + e.getMessage(), e);
+			}
+			
+			Node n = doc.getFirstChild();
+			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+			{
+				if (d.getNodeName().equals("mail"))
+				{
+					String mailId = d.getAttributes().getNamedItem("id").getNodeValue();
+					String subject = d.getAttributes().getNamedItem("subject").getNodeValue();
+					String maFile = d.getAttributes().getNamedItem("file").getNodeValue();
+					
+					try
+					{
+						FileInputStream fis = new FileInputStream("data/mail/"+maFile);
+						BufferedInputStream bis = new BufferedInputStream(fis);
+						int bytes = bis.available();
+						byte[] raw = new byte[bytes];
+						
+						bis.read(raw);
+						String html = new String(raw, "UTF-8");
+						html = html.replaceAll("\r\n", "\n");
+						html = html.replace("%servermail%", Config.EMAIL_SERVERINFO_ADDRESS);
+						html = html.replace("%servername%", Config.EMAIL_SERVERINFO_NAME);
+						
+						_mailData.put(mailId, new MailContent(subject, html));
+					}
+					catch (IOException e)
+					{
+						_log.warning("IOException while reading "+maFile);
+					}
+				}
+			}
+			_log.info("eMail System Loaded");
+		}
+		else
+			_log.warning("Cannot load eMail System - Missing file MailList.xml");
+	}
+	
+	class MailContent
+	{
+		private final String _subject;
+		private final String _text;
+		
+		/**
+		 * 
+		 */
+		public MailContent(String subject, String text)
+		{
+			_subject = subject;
+			_text = text;
+		}
+		
+		public String getSubject()
+		{
+			return _subject;
+		}
+		
+		public String getText()
+		{
+			return _text;
+		}
+	}
+	
+	public MailContent getMailContent(String mailId)
+	{
+		return _mailData.get(mailId);
+	}
+	
+	@SuppressWarnings("synthetic-access")
+	private static class SingletonHolder
+	{
+		protected static final MailSystem _instance = new MailSystem();
+	}
+}

+ 105 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/network/L2JGameServerPacketHandler.java

@@ -0,0 +1,105 @@
+/*
+ * 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.l2jserver.loginserver.network;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.loginserver.network.gameserverpackets.*;
+import com.l2jserver.loginserver.network.loginserverpackets.LoginServerFail;
+import com.l2jserver.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;
+		int opcode = data[0] & 0xff;
+		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:
+						if (Config.EMAIL_SYS_ENABLED)
+							msg = new RequestSendMail(data);
+						break;
+					case 0x0A:
+						msg = new RequestTempBan(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;
+	}
+}

+ 297 - 295
L2J_Server_BETA/java/com/l2jserver/loginserver/L2LoginClient.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/L2LoginClient.java

@@ -1,295 +1,297 @@
-/*
- * 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.l2jserver.loginserver;
-
-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 org.mmocore.network.MMOClient;
-import org.mmocore.network.MMOConnection;
-import org.mmocore.network.SendablePacket;
-
-import com.l2jserver.Config;
-import com.l2jserver.loginserver.serverpackets.L2LoginServerPacket;
-import com.l2jserver.loginserver.serverpackets.LoginFail;
-import com.l2jserver.loginserver.serverpackets.LoginFail.LoginFailReason;
-import com.l2jserver.loginserver.serverpackets.PlayFail;
-import com.l2jserver.loginserver.serverpackets.PlayFail.PlayFailReason;
-import com.l2jserver.util.Rnd;
-import com.l2jserver.util.crypt.LoginCrypt;
-import com.l2jserver.util.crypt.ScrambledKeyPair;
-
-/**
- * Represents a client connected into the LoginServer
- *
- * @author  KenM
- */
-public final class L2LoginClient extends MMOClient<MMOConnection<L2LoginClient>>
-{
-	private static Logger _log = Logger.getLogger(L2LoginClient.class.getName());
-	
-	public static enum LoginClientState { CONNECTED, AUTHED_GG, AUTHED_LOGIN}
-	
-	private LoginClientState _state;
-	
-	// Crypt
-	private LoginCrypt _loginCrypt;
-	private ScrambledKeyPair _scrambledPair;
-	private byte[] _blowfishKey;
-	
-	private String _account;
-	private int _accessLevel;
-	private int _lastServer;
-	private SessionKey _sessionKey;
-	private int _sessionId;
-	private boolean _joinedGS;
-	private Map<Integer, Integer> _charsOnServers;
-	private Map<Integer, long[]> _charsToDelete;
-	
-	private 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);
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.interfaces.MMOClient#decrypt(java.nio.ByteBuffer, int)
-	 */
-	@Override
-	public boolean decrypt(ByteBuffer buf, int size)
-	{
-		boolean ret = false;
-		try
-		{
-			ret = _loginCrypt.decrypt(buf.array(), buf.position(), size);
-		}
-		catch (IOException e)
-		{
-			e.printStackTrace();
-			super.getConnection().close((SendablePacket<L2LoginClient>)null);
-			return false;
-		}
-		
-		if (!ret)
-		{
-			byte[] dump = new byte[size];
-			System.arraycopy(buf.array(), buf.position(), dump, 0, size);
-			_log.warning("Wrong checksum from client: "+toString());
-			super.getConnection().close((SendablePacket<L2LoginClient>)null);
-		}
-		
-		return ret;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.interfaces.MMOClient#encrypt(java.nio.ByteBuffer, int)
-	 */
-	@Override
-	public boolean encrypt(ByteBuffer buf, int size)
-	{
-		final int offset = buf.position();
-		try
-		{
-			size = _loginCrypt.encrypt(buf.array(), offset, size);
-		}
-		catch (IOException e)
-		{
-			e.printStackTrace();
-			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<Integer, Integer>();
-		_charsOnServers.put(servId, chars);
-	}
-	
-	public Map<Integer, Integer> getCharsOnServ()
-	{
-		return _charsOnServers;
-	}
-	
-	public void serCharsWaitingDelOnServ(int servId, long[] charsToDel)
-	{
-		if (_charsToDelete == null)
-			_charsToDelete = new HashMap<Integer, long[]>();
-		_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()
-	{
-		InetAddress address = getConnection().getInetAddress();
-		if (getState() == LoginClientState.AUTHED_LOGIN)
-		{
-			return "["+getAccount()+" ("+(address == null ? "disconnected" : address.getHostAddress())+")]";
-		}
-		else
-		{
-			return "["+(address == null ? "disconnected" : address.getHostAddress())+"]";
-		}
-	}
-	
-	@Override
-	protected void onForcedDisconnection()
-	{
-		// Empty
-	}
-}
+/*
+ * 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.l2jserver.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 org.mmocore.network.MMOClient;
+import org.mmocore.network.MMOConnection;
+import org.mmocore.network.SendablePacket;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.loginserver.SessionKey;
+import com.l2jserver.loginserver.network.serverpackets.L2LoginServerPacket;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail;
+import com.l2jserver.loginserver.network.serverpackets.PlayFail;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
+import com.l2jserver.loginserver.network.serverpackets.PlayFail.PlayFailReason;
+import com.l2jserver.util.Rnd;
+import com.l2jserver.util.crypt.LoginCrypt;
+import com.l2jserver.util.crypt.ScrambledKeyPair;
+
+/**
+ * Represents a client connected into the LoginServer
+ *
+ * @author  KenM
+ */
+public final class L2LoginClient extends MMOClient<MMOConnection<L2LoginClient>>
+{
+	private static Logger _log = Logger.getLogger(L2LoginClient.class.getName());
+	
+	public static enum LoginClientState { CONNECTED, AUTHED_GG, AUTHED_LOGIN}
+	
+	private LoginClientState _state;
+	
+	// Crypt
+	private LoginCrypt _loginCrypt;
+	private ScrambledKeyPair _scrambledPair;
+	private byte[] _blowfishKey;
+	
+	private String _account;
+	private int _accessLevel;
+	private int _lastServer;
+	private SessionKey _sessionKey;
+	private int _sessionId;
+	private boolean _joinedGS;
+	private Map<Integer, Integer> _charsOnServers;
+	private Map<Integer, long[]> _charsToDelete;
+	
+	private 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);
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.interfaces.MMOClient#decrypt(java.nio.ByteBuffer, int)
+	 */
+	@Override
+	public boolean decrypt(ByteBuffer buf, int size)
+	{
+		boolean ret = false;
+		try
+		{
+			ret = _loginCrypt.decrypt(buf.array(), buf.position(), size);
+		}
+		catch (IOException e)
+		{
+			e.printStackTrace();
+			super.getConnection().close((SendablePacket<L2LoginClient>)null);
+			return false;
+		}
+		
+		if (!ret)
+		{
+			byte[] dump = new byte[size];
+			System.arraycopy(buf.array(), buf.position(), dump, 0, size);
+			_log.warning("Wrong checksum from client: "+toString());
+			super.getConnection().close((SendablePacket<L2LoginClient>)null);
+		}
+		
+		return ret;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.interfaces.MMOClient#encrypt(java.nio.ByteBuffer, int)
+	 */
+	@Override
+	public boolean encrypt(ByteBuffer buf, int size)
+	{
+		final int offset = buf.position();
+		try
+		{
+			size = _loginCrypt.encrypt(buf.array(), offset, size);
+		}
+		catch (IOException e)
+		{
+			e.printStackTrace();
+			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<Integer, Integer>();
+		_charsOnServers.put(servId, chars);
+	}
+	
+	public Map<Integer, Integer> getCharsOnServ()
+	{
+		return _charsOnServers;
+	}
+	
+	public void serCharsWaitingDelOnServ(int servId, long[] charsToDel)
+	{
+		if (_charsToDelete == null)
+			_charsToDelete = new HashMap<Integer, long[]>();
+		_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()
+	{
+		InetAddress address = getConnection().getInetAddress();
+		if (getState() == LoginClientState.AUTHED_LOGIN)
+		{
+			return "["+getAccount()+" ("+(address == null ? "disconnected" : address.getHostAddress())+")]";
+		}
+		else
+		{
+			return "["+(address == null ? "disconnected" : address.getHostAddress())+"]";
+		}
+	}
+	
+	@Override
+	protected void onForcedDisconnection()
+	{
+		// Empty
+	}
+}

+ 94 - 92
L2J_Server_BETA/java/com/l2jserver/loginserver/L2LoginPacketHandler.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/L2LoginPacketHandler.java

@@ -1,92 +1,94 @@
-/*
- * 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.l2jserver.loginserver;
-
-import java.nio.ByteBuffer;
-import java.util.logging.Logger;
-
-import org.mmocore.network.IPacketHandler;
-import org.mmocore.network.ReceivablePacket;
-
-import com.l2jserver.loginserver.L2LoginClient.LoginClientState;
-import com.l2jserver.loginserver.clientpackets.AuthGameGuard;
-import com.l2jserver.loginserver.clientpackets.RequestAuthLogin;
-import com.l2jserver.loginserver.clientpackets.RequestServerList;
-import com.l2jserver.loginserver.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());
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.IPacketHandler#handlePacket(java.nio.ByteBuffer, com.l2jserver.mmocore.interfaces.MMOClient)
-	 */
-	public ReceivablePacket<L2LoginClient> handlePacket(ByteBuffer buf, L2LoginClient client)
-	{
-		int opcode = buf.get() & 0xFF;
-		
-		ReceivablePacket<L2LoginClient> packet = null;
-		LoginClientState state = client.getState();
-		
-		switch (state)
-		{
-			case CONNECTED:
-				if (opcode == 0x07)
-				{
-					packet = new AuthGameGuard();
-				}
-				else
-				{
-					debugOpcode(opcode, state);
-				}
-				break;
-			case AUTHED_GG:
-				if (opcode == 0x00)
-				{
-					packet = new RequestAuthLogin();
-				}
-				else
-				{
-					debugOpcode(opcode, state);
-				}
-				break;
-			case AUTHED_LOGIN:
-				if (opcode == 0x05)
-				{
-					packet = new RequestServerList();
-				}
-				else if (opcode == 0x02)
-				{
-					packet = new RequestServerLogin();
-				}
-				else
-				{
-					debugOpcode(opcode, state);
-				}
-				break;
-		}
-		return packet;
-	}
-	
-	private void debugOpcode(int opcode, LoginClientState state)
-	{
-		_log.info("Unknown Opcode: "+opcode+" for state: "+state.name());
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network;
+
+import java.nio.ByteBuffer;
+import java.util.logging.Logger;
+
+import org.mmocore.network.IPacketHandler;
+import org.mmocore.network.ReceivablePacket;
+
+import com.l2jserver.loginserver.network.L2LoginClient.LoginClientState;
+import com.l2jserver.loginserver.network.clientpackets.AuthGameGuard;
+import com.l2jserver.loginserver.network.clientpackets.RequestAuthLogin;
+import com.l2jserver.loginserver.network.clientpackets.RequestServerList;
+import com.l2jserver.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());
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.IPacketHandler#handlePacket(java.nio.ByteBuffer, com.l2jserver.mmocore.interfaces.MMOClient)
+	 */
+	public ReceivablePacket<L2LoginClient> handlePacket(ByteBuffer buf, L2LoginClient client)
+	{
+		int opcode = buf.get() & 0xFF;
+		
+		ReceivablePacket<L2LoginClient> packet = null;
+		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());
+	}
+}

+ 96 - 96
L2J_Server_BETA/java/com/l2jserver/loginserver/clientpackets/AuthGameGuard.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/AuthGameGuard.java

@@ -1,96 +1,96 @@
-/*
- * 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.l2jserver.loginserver.clientpackets;
-
-import com.l2jserver.loginserver.L2LoginClient.LoginClientState;
-import com.l2jserver.loginserver.serverpackets.GGAuth;
-import com.l2jserver.loginserver.serverpackets.LoginFail.LoginFailReason;
-
-/**
- * @author -Wooden-
- * Format: ddddd
- *
- */
-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;
-	}
-	
-	/**
-	 * @see com.l2jserver.loginserver.clientpackets.L2LoginClientPacket#readImpl()
-	 */
-	@Override
-	protected boolean readImpl()
-	{
-		if (super._buf.remaining() >= 20)
-		{
-			_sessionId = readD();
-			_data1 = readD();
-			_data2 = readD();
-			_data3 = readD();
-			_data4 = readD();
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
-	 */
-	@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);
-		}
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.clientpackets;
+
+import com.l2jserver.loginserver.network.L2LoginClient.LoginClientState;
+import com.l2jserver.loginserver.network.serverpackets.GGAuth;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
+
+/**
+ * @author -Wooden-
+ * Format: ddddd
+ *
+ */
+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;
+	}
+	
+	/**
+	 * @see com.l2jserver.loginserver.network.clientpackets.L2LoginClientPacket#readImpl()
+	 */
+	@Override
+	protected boolean readImpl()
+	{
+		if (super._buf.remaining() >= 20)
+		{
+			_sessionId = readD();
+			_data1 = readD();
+			_data2 = readD();
+			_data3 = readD();
+			_data4 = readD();
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
+	 */
+	@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);
+		}
+	}
+}

+ 50 - 50
L2J_Server_BETA/java/com/l2jserver/loginserver/clientpackets/L2LoginClientPacket.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/L2LoginClientPacket.java

@@ -1,50 +1,50 @@
-/*
- * 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.l2jserver.loginserver.clientpackets;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.mmocore.network.ReceivablePacket;
-
-import com.l2jserver.loginserver.L2LoginClient;
-
-/**
- *
- * @author  KenM
- */
-public abstract class L2LoginClientPacket extends ReceivablePacket<L2LoginClient>
-{
-	private static Logger _log = Logger.getLogger(L2LoginClientPacket.class.getName());
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.ReceivablePacket#read()
-	 */
-	@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();
-}
+/*
+ * 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.l2jserver.loginserver.network.clientpackets;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.mmocore.network.ReceivablePacket;
+
+import com.l2jserver.loginserver.network.L2LoginClient;
+
+/**
+ *
+ * @author  KenM
+ */
+public abstract class L2LoginClientPacket extends ReceivablePacket<L2LoginClient>
+{
+	private static Logger _log = Logger.getLogger(L2LoginClientPacket.class.getName());
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.ReceivablePacket#read()
+	 */
+	@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();
+}

+ 173 - 173
L2J_Server_BETA/java/com/l2jserver/loginserver/clientpackets/RequestAuthLogin.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/RequestAuthLogin.java

@@ -1,173 +1,173 @@
-/*
- * 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.l2jserver.loginserver.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.l2jserver.Config;
-import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
-import com.l2jserver.loginserver.HackingException;
-import com.l2jserver.loginserver.L2LoginClient;
-import com.l2jserver.loginserver.L2LoginClient.LoginClientState;
-import com.l2jserver.loginserver.LoginController;
-import com.l2jserver.loginserver.LoginController.AuthLoginResult;
-import com.l2jserver.loginserver.serverpackets.AccountKicked;
-import com.l2jserver.loginserver.serverpackets.AccountKicked.AccountKickedReason;
-import com.l2jserver.loginserver.serverpackets.LoginFail.LoginFailReason;
-import com.l2jserver.loginserver.serverpackets.LoginOk;
-import com.l2jserver.loginserver.serverpackets.ServerList;
-
-
-/**
- * Format: x
- * 0 (a leading null)
- * x: the rsa encrypted block with the login an password
- */
-public class RequestAuthLogin extends L2LoginClientPacket
-{
-	private static Logger _log = Logger.getLogger(RequestAuthLogin.class.getName());
-	
-	private byte[] _raw = new byte[128];
-	
-	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() >= 128)
-		{
-			readB(_raw);
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	
-	@Override
-	public void run()
-	{
-		byte[] decrypted = null;
-		L2LoginClient client = getClient();
-		try
-		{
-			Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
-			rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey());
-			decrypted = rsaCipher.doFinal(_raw, 0x00, 0x80 );
-		}
-		catch (GeneralSecurityException e)
-		{
-			_log.log(Level.INFO, "" , e);
-			return;
-		}
-		
-		_user = new String(decrypted, 0x5E, 14 ).trim();
-		_user = _user.toLowerCase();
-		_password = new String(decrypted, 0x6C, 16).trim();
-		_ncotp = decrypted[0x7c];
-		_ncotp |= decrypted[0x7d] << 8;
-		_ncotp |= decrypted[0x7e] << 16;
-		_ncotp |= decrypted[0x7f] << 24;
-		
-		LoginController lc = LoginController.getInstance();
-		try
-		{
-			AuthLoginResult result = lc.tryAuthLogin(_user, _password, client);
-			
-			switch (result)
-			{
-				case AUTH_SUCCESS:
-					client.setAccount(_user);
-					lc.getCharactersOnAccount(_user);
-					client.setState(LoginClientState.AUTHED_LOGIN);
-					client.setSessionKey(lc.assignSessionKeyToClient(_user, client));
-					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));
-					break;
-				case ALREADY_ON_LS:
-					L2LoginClient oldClient;
-					if ((oldClient = lc.getAuthedClient(_user)) != null)
-					{
-						// kick the other client
-						oldClient.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
-						lc.removeAuthedLoginClient(_user);
-					}
-					// kick also current client
-					client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
-					break;
-				case ALREADY_ON_GS:
-					GameServerInfo gsi;
-					if ((gsi = lc.getAccountOnGameServer(_user)) != null)
-					{
-						client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
-						
-						// kick from there
-						if (gsi.isAuthed())
-						{
-							gsi.getGameServerThread().kickPlayer(_user);
-						}
-					}
-					break;
-			}
-		}
-		catch (HackingException e)
-		{
-			InetAddress address = getClient().getConnection().getInetAddress();
-			lc.addBanForAddress(address, Config.LOGIN_BLOCK_AFTER_BAN*1000);
-			_log.info("Banned ("+address+") for "+Config.LOGIN_BLOCK_AFTER_BAN+" seconds, due to "+e.getConnects()+" incorrect login attempts.");
-		}
-	}
-}
+/*
+ * 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.l2jserver.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.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
+import com.l2jserver.loginserver.HackingException;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.loginserver.LoginController.AuthLoginResult;
+import com.l2jserver.loginserver.network.L2LoginClient;
+import com.l2jserver.loginserver.network.L2LoginClient.LoginClientState;
+import com.l2jserver.loginserver.network.serverpackets.AccountKicked;
+import com.l2jserver.loginserver.network.serverpackets.LoginOk;
+import com.l2jserver.loginserver.network.serverpackets.ServerList;
+import com.l2jserver.loginserver.network.serverpackets.AccountKicked.AccountKickedReason;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
+
+
+/**
+ * Format: x
+ * 0 (a leading null)
+ * x: the rsa encrypted block with the login an password
+ */
+public class RequestAuthLogin extends L2LoginClientPacket
+{
+	private static Logger _log = Logger.getLogger(RequestAuthLogin.class.getName());
+	
+	private byte[] _raw = new byte[128];
+	
+	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() >= 128)
+		{
+			readB(_raw);
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+	
+	@Override
+	public void run()
+	{
+		byte[] decrypted = null;
+		L2LoginClient client = getClient();
+		try
+		{
+			Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
+			rsaCipher.init(Cipher.DECRYPT_MODE, client.getRSAPrivateKey());
+			decrypted = rsaCipher.doFinal(_raw, 0x00, 0x80 );
+		}
+		catch (GeneralSecurityException e)
+		{
+			_log.log(Level.INFO, "" , e);
+			return;
+		}
+		
+		_user = new String(decrypted, 0x5E, 14 ).trim();
+		_user = _user.toLowerCase();
+		_password = new String(decrypted, 0x6C, 16).trim();
+		_ncotp = decrypted[0x7c];
+		_ncotp |= decrypted[0x7d] << 8;
+		_ncotp |= decrypted[0x7e] << 16;
+		_ncotp |= decrypted[0x7f] << 24;
+		
+		LoginController lc = LoginController.getInstance();
+		try
+		{
+			AuthLoginResult result = lc.tryAuthLogin(_user, _password, client);
+			
+			switch (result)
+			{
+				case AUTH_SUCCESS:
+					client.setAccount(_user);
+					lc.getCharactersOnAccount(_user);
+					client.setState(LoginClientState.AUTHED_LOGIN);
+					client.setSessionKey(lc.assignSessionKeyToClient(_user, client));
+					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));
+					break;
+				case ALREADY_ON_LS:
+					L2LoginClient oldClient;
+					if ((oldClient = lc.getAuthedClient(_user)) != null)
+					{
+						// kick the other client
+						oldClient.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
+						lc.removeAuthedLoginClient(_user);
+					}
+					// kick also current client
+					client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
+					break;
+				case ALREADY_ON_GS:
+					GameServerInfo gsi;
+					if ((gsi = lc.getAccountOnGameServer(_user)) != null)
+					{
+						client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
+						
+						// kick from there
+						if (gsi.isAuthed())
+						{
+							gsi.getGameServerThread().kickPlayer(_user);
+						}
+					}
+					break;
+			}
+		}
+		catch (HackingException e)
+		{
+			InetAddress address = getClient().getConnection().getInetAddress();
+			lc.addBanForAddress(address, Config.LOGIN_BLOCK_AFTER_BAN*1000);
+			_log.info("Banned ("+address+") for "+Config.LOGIN_BLOCK_AFTER_BAN+" seconds, due to "+e.getConnects()+" incorrect login attempts.");
+		}
+	}
+}

+ 86 - 86
L2J_Server_BETA/java/com/l2jserver/loginserver/clientpackets/RequestServerList.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/RequestServerList.java

@@ -1,86 +1,86 @@
-/*
- * 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.l2jserver.loginserver.clientpackets;
-
-import com.l2jserver.loginserver.serverpackets.LoginFail.LoginFailReason;
-import com.l2jserver.loginserver.serverpackets.ServerList;
-
-/**
- * Format: ddc
- * d: fist part of session id
- * d: second part of session id
- * c: ?
- */
-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;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
-	 */
-	@Override
-	public void run()
-	{
-		if (getClient().getSessionKey().checkLoginPair(_skey1, _skey2))
-		{
-			getClient().sendPacket(new ServerList(getClient()));
-		}
-		else
-		{
-			getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
-		}
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.clientpackets;
+
+import com.l2jserver.loginserver.network.serverpackets.ServerList;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
+
+/**
+ * Format: ddc
+ * d: fist part of session id
+ * d: second part of session id
+ * c: ?
+ */
+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;
+		}
+		else
+		{
+			return false;
+		}
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
+	 */
+	@Override
+	public void run()
+	{
+		if (getClient().getSessionKey().checkLoginPair(_skey1, _skey2))
+		{
+			getClient().sendPacket(new ServerList(getClient()));
+		}
+		else
+		{
+			getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
+		}
+	}
+}

+ 102 - 102
L2J_Server_BETA/java/com/l2jserver/loginserver/clientpackets/RequestServerLogin.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/clientpackets/RequestServerLogin.java

@@ -1,102 +1,102 @@
-/*
- * 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.l2jserver.loginserver.clientpackets;
-
-import com.l2jserver.Config;
-import com.l2jserver.loginserver.LoginController;
-import com.l2jserver.loginserver.SessionKey;
-import com.l2jserver.loginserver.serverpackets.LoginFail.LoginFailReason;
-import com.l2jserver.loginserver.serverpackets.PlayFail.PlayFailReason;
-import com.l2jserver.loginserver.serverpackets.PlayOk;
-
-/**
- * Fromat is ddc
- * d: first part of session id
- * d: second part of session id
- * c: server ID
- */
-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;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
-	 */
-	@Override
-	public void run()
-	{
-		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);
-		}
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.clientpackets;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.loginserver.SessionKey;
+import com.l2jserver.loginserver.network.serverpackets.PlayOk;
+import com.l2jserver.loginserver.network.serverpackets.LoginFail.LoginFailReason;
+import com.l2jserver.loginserver.network.serverpackets.PlayFail.PlayFailReason;
+
+/**
+ * Fromat is ddc
+ * d: first part of session id
+ * d: second part of session id
+ * c: server ID
+ */
+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;
+		}
+		else
+		{
+			return false;
+		}
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
+	 */
+	@Override
+	public void run()
+	{
+		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);
+		}
+	}
+}

+ 74 - 76
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/BlowFishKey.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/BlowFishKey.java

@@ -1,76 +1,74 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import java.security.GeneralSecurityException;
-import java.security.interfaces.RSAPrivateKey;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.crypto.Cipher;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-
-/**
- * @author -Wooden-
- *
- */
-public class BlowFishKey extends BaseRecievePacket
-{
-	byte[] _key;
-	protected static final Logger _log = Logger.getLogger(BlowFishKey.class.getName());
-	/**
-	 * @param decrypt
-	 */
-	public BlowFishKey(byte[] decrypt, RSAPrivateKey privateKey)
-	{
-		super(decrypt);
-		int size = readD();
-		byte[] tempKey = readB(size);
-		try
-		{
-			byte [] tempDecryptKey;
-			Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
-			rsaCipher.init(Cipher.DECRYPT_MODE, privateKey);
-			tempDecryptKey = rsaCipher.doFinal(tempKey);
-			// there are nulls before the key we must remove them
-			int i = 0;
-			int len = tempDecryptKey.length;
-			for(; i < len; i++)
-			{
-				if(tempDecryptKey[i] != 0)
-					break;
-			}
-			_key = new byte[len-i];
-			System.arraycopy(tempDecryptKey,i,_key,0,len-i);
-		}
-		catch(GeneralSecurityException e)
-		{
-			_log.log(Level.SEVERE, "Error While decrypting blowfish key (RSA): " + e.getMessage(), e);
-		}
-		/*catch(IOException ioe)
-		{
-			//TODO: manage
-		}*/
-		
-	}
-	
-	public byte[] getKey()
-	{
-		return _key;
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.security.GeneralSecurityException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.crypto.Cipher;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.loginserver.network.L2JGameServerPacketHandler.GameServerState;
+import com.l2jserver.util.crypt.NewCrypt;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class BlowFishKey extends BaseRecievePacket
+{
+	protected static final Logger _log = Logger.getLogger(BlowFishKey.class.getName());
+	/**
+	 * @param decrypt
+	 */
+	public BlowFishKey(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		int size = readD();
+		byte[] tempKey = readB(size);
+		try
+		{
+			byte [] tempDecryptKey;
+			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;
+			int len = tempDecryptKey.length;
+			for(; i < len; i++)
+			{
+				if(tempDecryptKey[i] != 0)
+					break;
+			}
+			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);
+		}
+	}
+}

+ 43 - 55
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/ChangeAccessLevel.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/ChangeAccessLevel.java

@@ -1,55 +1,43 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-/**
- * @author -Wooden-
- *
- */
-public class ChangeAccessLevel extends BaseRecievePacket
-{
-	
-	private int _level;
-	private String _account;
-	
-	/**
-	 * @param decrypt
-	 */
-	public ChangeAccessLevel(byte[] decrypt)
-	{
-		super(decrypt);
-		_level = readD();
-		_account = readS();
-	}
-	
-	/**
-	 * @return Returns the account.
-	 */
-	public String getAccount()
-	{
-		return _account;
-	}
-	
-	/**
-	 * @return Returns the level.
-	 */
-	public int getLevel()
-	{
-		return _level;
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class ChangeAccessLevel extends BaseRecievePacket
+{
+	protected static Logger _log = Logger.getLogger(ChangeAccessLevel.class.getName());
+	
+	/**
+	 * @param decrypt
+	 */
+	public ChangeAccessLevel(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		int level = readD();
+		String account = readS();
+		
+		LoginController.getInstance().setAccountAccessLevel(account, level);
+		_log.info("Changed "+account+" access level to "+level);
+	}	
+}

+ 172 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/GameServerAuth.java

@@ -0,0 +1,172 @@
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.loginserver.network.L2JGameServerPacketHandler.GameServerState;
+import com.l2jserver.loginserver.network.loginserverpackets.AuthResponse;
+import com.l2jserver.loginserver.network.loginserverpackets.LoginServerFail;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+
+/**
+ * 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 BaseRecievePacket
+{
+	protected static Logger _log = Logger.getLogger(GameServerAuth.class.getName());
+	GameServerThread _server;
+	private byte[] _hexId;
+	private int _desiredId;
+	@SuppressWarnings("unused")
+	private boolean _hostReserved;
+	private boolean _acceptAlternativeId;
+	private int _maxPlayers;
+	private int _port;
+	private String[] _hosts;
+	
+	/**
+	 * @param decrypt
+	 */
+	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())
+		{
+			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()
+	{
+		GameServerTable gameServerTable = GameServerTable.getInstance();
+		
+		int id = _desiredId;
+		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;
+					}
+					else
+					{
+						_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.registerWithFirstAvaliableId(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;
+	}
+}

+ 74 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerAuthRequest.java

@@ -0,0 +1,74 @@
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.loginserver.SessionKey;
+import com.l2jserver.loginserver.network.loginserverpackets.PlayerAuthResponse;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class PlayerAuthRequest extends BaseRecievePacket
+{	
+	private static Logger _log = Logger.getLogger(PlayerAuthRequest.class.getName());
+	
+	/**
+	 * @param decrypt
+	 */
+	public PlayerAuthRequest(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		String account = readS();
+		int playKey1 = readD();
+		int playKey2 = readD();
+		int loginKey1 = readD();
+		int loginKey2 = readD();
+		SessionKey sessionKey = new SessionKey(loginKey1, loginKey2, playKey1, playKey2);
+		
+		PlayerAuthResponse authResponse;
+		if (Config.DEBUG)
+		{
+			_log.info("auth request received for Player "+account);
+		}
+		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);
+	}
+}

+ 50 - 53
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/PlayerInGame.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerInGame.java

@@ -1,53 +1,50 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import java.util.List;
-
-import javolution.util.FastList;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-/**
- * @author -Wooden-
- *
- */
-public class PlayerInGame extends BaseRecievePacket
-{
-	private List<String> _accounts;
-	
-	/**
-	 * @param decrypt
-	 */
-	public PlayerInGame(byte[] decrypt)
-	{
-		super(decrypt);
-		_accounts =  new FastList<String>();
-		int size = readH();
-		for (int i = 0; i < size; i++)
-		{
-			_accounts.add(readS());
-		}
-	}
-	
-	/**
-	 * @return Returns the accounts.
-	 */
-	public List<String> getAccounts()
-	{
-		return _accounts;
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class PlayerInGame extends BaseRecievePacket
+{
+	private static Logger _log = Logger.getLogger(PlayerInGame.class.getName());
+	
+	/**
+	 * @param decrypt
+	 */
+	public PlayerInGame(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		int size = readH();
+		for (int i = 0; i < size; i++)
+		{
+			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());
+		}
+	}
+}

+ 48 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerLogout.java

@@ -0,0 +1,48 @@
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class PlayerLogout extends BaseRecievePacket
+{
+	protected static Logger _log = Logger.getLogger(PlayerLogout.class.getName());
+	
+	/**
+	 * @param decrypt
+	 */
+	public PlayerLogout(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		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());
+	}
+}

+ 50 - 61
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/PlayerAuthRequest.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/PlayerTracert.java

@@ -1,61 +1,50 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import com.l2jserver.loginserver.SessionKey;
-import com.l2jserver.util.network.BaseRecievePacket;
-
-/**
- * @author -Wooden-
- *
- */
-public class PlayerAuthRequest extends BaseRecievePacket
-{
-	
-	private String _account;
-	private SessionKey _sessionKey;
-	
-	
-	/**
-	 * @param decrypt
-	 */
-	public PlayerAuthRequest(byte[] decrypt)
-	{
-		super(decrypt);
-		_account = readS();
-		int playKey1 = readD();
-		int playKey2 = readD();
-		int loginKey1 = readD();
-		int loginKey2 = readD();
-		_sessionKey = new SessionKey(loginKey1, loginKey2, playKey1, playKey2);
-	}
-	
-	/**
-	 * @return Returns the account.
-	 */
-	public String getAccount()
-	{
-		return _account;
-	}
-	
-	/**
-	 * @return Returns the key.
-	 */
-	public SessionKey getKey()
-	{
-		return _sessionKey;
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.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);
+		String account = readS();
+		String pcIp = readS();
+		String hop1 = readS();
+		String hop2 = readS();
+		String hop3 = readS();
+		String hop4 = readS();
+		
+		LoginController.getInstance().setAccountLastTracert(account, pcIp, hop1, hop2, hop3, hop4);
+		if (Config.DEBUG)
+		{
+			_log.info("Saved "+account+" last tracert");
+		}
+	}
+}

+ 44 - 75
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/ReplyCharacters.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/ReplyCharacters.java

@@ -1,75 +1,44 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-/**
- * @author mrTJO
- * Thanks to mochitto
- */
-public class ReplyCharacters extends BaseRecievePacket
-{
-	String _account;
-	int _chars;
-	long[] _charsList;
-	/**
-	 * @param decrypt
-	 */
-	public ReplyCharacters(byte[] decrypt)
-	{
-		super(decrypt);
-		_account = readS();
-		_chars = readC();
-		int charsToDel = readC();
-		_charsList = new long[charsToDel];
-		for (int i = 0; i < charsToDel; i++)
-		{
-			_charsList[i] = readQ();
-		}
-	}
-	
-	/**
-	 * @return Account Name
-	 */
-	public String getAccountName()
-	{
-		return _account;
-	}
-	
-	/**
-	 * @return Number of Characters on Server
-	 */
-	public int getCharsOnServer()
-	{
-		return _chars;
-	}
-	
-	/**
-	 * @return Number of Characters on Server Waiting for Delete
-	 */
-	public int getCharsWaitingDel()
-	{
-		return _charsList.length;
-	}
-	
-	/**
-	 * @return Array with Time to Character Delete
-	 */
-	public long[] getTimeToDelForChars()
-	{
-		return _charsList;
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author mrTJO
+ * Thanks to mochitto
+ */
+public class ReplyCharacters extends BaseRecievePacket
+{
+	/**
+	 * @param decrypt
+	 */
+	public ReplyCharacters(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		String account = readS();
+		int chars = readC();
+		int charsToDel = readC();
+		long[] charsList = new long[charsToDel];
+		for (int i = 0; i < charsToDel; i++)
+		{
+			charsList[i] = readQ();
+		}
+		LoginController.getInstance().setCharactersOnServer(account,
+				chars, charsList, server.getServerId());
+	}
+}

+ 46 - 45
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/PlayerLogout.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/RequestSendMail.java

@@ -1,45 +1,46 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import com.l2jserver.util.network.BaseRecievePacket;
-
-/**
- * @author -Wooden-
- *
- */
-public class PlayerLogout extends BaseRecievePacket
-{
-	
-	private String _account;
-	
-	/**
-	 * @param decrypt
-	 */
-	public PlayerLogout(byte[] decrypt)
-	{
-		super(decrypt);
-		_account = readS();
-	}
-	
-	/**
-	 * @return Returns the account.
-	 */
-	public String getAccount()
-	{
-		return _account;
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import com.l2jserver.loginserver.mail.MailSystem;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class RequestSendMail extends BaseRecievePacket
+{
+	String _accountName, _mailId;
+	String[] _args;
+	
+	/**
+	 * @param decrypt
+	 */
+	public RequestSendMail(byte[] decrypt)
+	{
+		super(decrypt);
+		_accountName = readS();
+		_mailId = readS();
+		int argNum = readC();
+		_args = new String[argNum];
+		for (int i = 0; i < argNum; i++)
+		{
+			_args[i] = readS();
+		}
+		
+		MailSystem.getInstance().sendMail(_accountName, _mailId, _args);
+	}
+}

+ 84 - 0
L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/RequestTempBan.java

@@ -0,0 +1,84 @@
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.net.UnknownHostException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.loginserver.LoginController;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * 
+ * @author mrTJO
+ */
+public class RequestTempBan extends BaseRecievePacket
+{
+	String _accountName, _banReason, _ip;
+	long _banTime;
+	
+	/**
+	 * @param decrypt
+	 */
+	public RequestTempBan(byte[] decrypt)
+	{
+		super(decrypt);
+		_accountName = readS();
+		_ip = readS();
+		_banTime = readQ();
+		boolean haveReason = readC() == 0 ? false : true;
+		if (haveReason)
+		{
+			_banReason = readS();
+		}
+		banUser();
+	}
+	
+	private void banUser()
+	{
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("INSERT INTO account_data VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value=?");
+			statement.setString(1, _accountName);
+			statement.setString(2, "ban_temp");
+			statement.setString(3, Long.toString(_banTime));
+			statement.setString(4, Long.toString(_banTime));
+			statement.execute();
+			statement.close();
+		}
+		catch (SQLException e)
+		{
+			e.printStackTrace();
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+		
+		try
+		{
+			LoginController.getInstance().addBanForAddress(_ip, _banTime);
+		}
+		catch (UnknownHostException e)
+		{
+			
+		}
+	}
+}

+ 103 - 102
L2J_Server_BETA/java/com/l2jserver/loginserver/gameserverpackets/ServerStatus.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/gameserverpackets/ServerStatus.java

@@ -1,102 +1,103 @@
-/*
- * 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.l2jserver.loginserver.gameserverpackets;
-
-import java.util.logging.Logger;
-
-import com.l2jserver.loginserver.GameServerTable;
-import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
-import com.l2jserver.util.network.BaseRecievePacket;
-
-
-/**
- * @author -Wooden-
- *
- */
-public class ServerStatus extends BaseRecievePacket
-{
-	protected static Logger _log = Logger.getLogger(ServerStatus.class.getName());
-	
-	public static final String [] STATUS_STRING = {"Auto", "Good", "Normal", "Full", "Down", "Gm Only"};
-	
-	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
-	 */
-	public ServerStatus(byte[] decrypt, int serverId)
-	{
-		super(decrypt);
-		
-		GameServerInfo gsi = GameServerTable.getInstance().getRegisteredGameServerById(serverId);
-		if (gsi != null)
-		{
-			int size = readD();
-			for (int i = 0; i < size; i++)
-			{
-				int type = readD();
-				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;
-				}
-			}
-		}
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.gameserverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class ServerStatus extends BaseRecievePacket
+{
+	protected static Logger _log = Logger.getLogger(ServerStatus.class.getName());
+	
+	public static final String [] STATUS_STRING = {"Auto", "Good", "Normal", "Full", "Down", "Gm Only"};
+	
+	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
+	 */
+	public ServerStatus(byte[] decrypt, GameServerThread server)
+	{
+		super(decrypt);
+		
+		GameServerInfo gsi = GameServerTable.getInstance().getRegisteredGameServerById(server.getServerId());
+		if (gsi != null)
+		{
+			int size = readD();
+			for (int i = 0; i < size; i++)
+			{
+				int type = readD();
+				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;
+				}
+			}
+		}
+	}
+}

+ 49 - 49
L2J_Server_BETA/java/com/l2jserver/loginserver/loginserverpackets/AuthResponse.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/AuthResponse.java

@@ -1,49 +1,49 @@
-/*
- * 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.l2jserver.loginserver.loginserverpackets;
-
-import java.io.IOException;
-
-import com.l2jserver.loginserver.GameServerTable;
-import com.l2jserver.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));
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.l2jserver.loginserver.serverpackets.ServerBasePacket#getContent()
-	 */
-	@Override
-	public byte[] getContent() throws IOException
-	{
-		return getBytes();
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.loginserverpackets;
+
+import java.io.IOException;
+
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.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));
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.loginserver.serverpackets.ServerBasePacket#getContent()
+	 */
+	@Override
+	public byte[] getContent() throws IOException
+	{
+		return getBytes();
+	}
+	
+}

+ 45 - 45
L2J_Server_BETA/java/com/l2jserver/loginserver/loginserverpackets/InitLS.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/InitLS.java

@@ -1,45 +1,45 @@
-/*
- * 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.l2jserver.loginserver.loginserverpackets;
-
-import com.l2jserver.loginserver.L2LoginServer;
-import com.l2jserver.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();
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.loginserverpackets;
+
+import com.l2jserver.loginserver.L2LoginServer;
+import com.l2jserver.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();
+	}
+}

+ 43 - 43
L2J_Server_BETA/java/com/l2jserver/loginserver/loginserverpackets/KickPlayer.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/KickPlayer.java

@@ -1,43 +1,43 @@
-/*
- * 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.l2jserver.loginserver.loginserverpackets;
-
-import java.io.IOException;
-
-import com.l2jserver.util.network.BaseSendablePacket;
-
-
-/**
- * @author -Wooden-
- *
- */
-public class KickPlayer extends BaseSendablePacket
-{
-	public KickPlayer(String account)
-	{
-		writeC(0x04);
-		writeS(account);
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.l2jserver.loginserver.serverpackets.ServerBasePacket#getContent()
-	 */
-	@Override
-	public byte[] getContent() throws IOException
-	{
-		return getBytes();
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.loginserverpackets;
+
+import java.io.IOException;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class KickPlayer extends BaseSendablePacket
+{
+	public KickPlayer(String account)
+	{
+		writeC(0x04);
+		writeS(account);
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.loginserver.serverpackets.ServerBasePacket#getContent()
+	 */
+	@Override
+	public byte[] getContent() throws IOException
+	{
+		return getBytes();
+	}
+	
+}

+ 49 - 49
L2J_Server_BETA/java/com/l2jserver/loginserver/loginserverpackets/LoginServerFail.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/LoginServerFail.java

@@ -1,49 +1,49 @@
-/*
- * 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.l2jserver.loginserver.loginserverpackets;
-
-import com.l2jserver.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;
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.loginserverpackets;
+
+import com.l2jserver.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;
+	
+}

+ 44 - 44
L2J_Server_BETA/java/com/l2jserver/loginserver/loginserverpackets/PlayerAuthResponse.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/PlayerAuthResponse.java

@@ -1,44 +1,44 @@
-/*
- * 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.l2jserver.loginserver.loginserverpackets;
-
-import java.io.IOException;
-
-import com.l2jserver.util.network.BaseSendablePacket;
-
-
-/**
- * @author -Wooden-
- *
- */
-public class PlayerAuthResponse extends BaseSendablePacket
-{
-	public PlayerAuthResponse(String account, boolean response)
-	{
-		writeC(0x03);
-		writeS(account);
-		writeC(response ? 1 : 0);
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.l2jserver.loginserver.serverpackets.ServerBasePacket#getContent()
-	 */
-	@Override
-	public byte[] getContent() throws IOException
-	{
-		return getBytes();
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.loginserverpackets;
+
+import java.io.IOException;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+
+/**
+ * @author -Wooden-
+ *
+ */
+public class PlayerAuthResponse extends BaseSendablePacket
+{
+	public PlayerAuthResponse(String account, boolean response)
+	{
+		writeC(0x03);
+		writeS(account);
+		writeC(response ? 1 : 0);
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.loginserver.serverpackets.ServerBasePacket#getContent()
+	 */
+	@Override
+	public byte[] getContent() throws IOException
+	{
+		return getBytes();
+	}
+	
+}

+ 42 - 42
L2J_Server_BETA/java/com/l2jserver/loginserver/loginserverpackets/RequestCharacters.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/loginserverpackets/RequestCharacters.java

@@ -1,42 +1,42 @@
-/*
- * 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.l2jserver.loginserver.loginserverpackets;
-
-import java.io.IOException;
-
-import com.l2jserver.util.network.BaseSendablePacket;
-
-/**
- * @author mrTJO
- * Thanks to mochitto
- */
-public class RequestCharacters extends BaseSendablePacket
-{
-	public RequestCharacters(String account)
-	{
-		writeC(0x05);
-		writeS(account);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.l2jserver.util.network.BaseSendablePacket#getContent()
-	 */
-	@Override
-	public byte[] getContent() throws IOException
-	{
-		return getBytes();
-	}
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.loginserverpackets;
+
+import java.io.IOException;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+/**
+ * @author mrTJO
+ * Thanks to mochitto
+ */
+public class RequestCharacters extends BaseSendablePacket
+{
+	public RequestCharacters(String account)
+	{
+		writeC(0x05);
+		writeS(account);
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jserver.util.network.BaseSendablePacket#getContent()
+	 */
+	@Override
+	public byte[] getContent() throws IOException
+	{
+		return getBytes();
+	}
+	
+}

+ 60 - 60
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/AccountKicked.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/AccountKicked.java

@@ -1,60 +1,60 @@
-/*
- * 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.l2jserver.loginserver.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 AccountKickedReason _reason;
-	
-	public AccountKicked(AccountKickedReason reason)
-	{
-		_reason = reason;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@Override
-	protected void write()
-	{
-		writeC(0x02);
-		writeD(_reason.getCode());
-	}
-	
-}
+/*
+ * 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.l2jserver.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 AccountKickedReason _reason;
+	
+	public AccountKicked(AccountKickedReason reason)
+	{
+		_reason = reason;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@Override
+	protected void write()
+	{
+		writeC(0x02);
+		writeD(_reason.getCode());
+	}
+	
+}

+ 56 - 56
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/GGAuth.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/GGAuth.java

@@ -1,56 +1,56 @@
-/*
- * 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.l2jserver.loginserver.serverpackets;
-
-import java.util.logging.Logger;
-
-import com.l2jserver.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 int _response;
-	
-	public GGAuth(int response)
-	{
-		_response = response;
-		if (Config.DEBUG)
-		{
-			_log.warning("Reason Hex: "+(Integer.toHexString(response)));
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@Override
-	protected void write()
-	{
-		writeC(0x0b);
-		writeD(_response);
-		writeD(0x00);
-		writeD(0x00);
-		writeD(0x00);
-		writeD(0x00);
-	}
-}
-
+/*
+ * 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.l2jserver.loginserver.network.serverpackets;
+
+import java.util.logging.Logger;
+
+import com.l2jserver.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 int _response;
+	
+	public GGAuth(int response)
+	{
+		_response = response;
+		if (Config.DEBUG)
+		{
+			_log.warning("Reason Hex: "+(Integer.toHexString(response)));
+		}
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@Override
+	protected void write()
+	{
+		writeC(0x0b);
+		writeD(_response);
+		writeD(0x00);
+		writeD(0x00);
+		writeD(0x00);
+		writeD(0x00);
+	}
+}
+

+ 73 - 73
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/Init.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/Init.java

@@ -1,73 +1,73 @@
-/*
- * 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.l2jserver.loginserver.serverpackets;
-
-import com.l2jserver.loginserver.L2LoginClient;
-
-/**
- * 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 L2LoginServerPacket
-{
-	private int _sessionId;
-	
-	private byte[] _publicKey;
-	private 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;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@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 ;)
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.serverpackets;
+
+import com.l2jserver.loginserver.network.L2LoginClient;
+
+/**
+ * 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 L2LoginServerPacket
+{
+	private int _sessionId;
+	
+	private byte[] _publicKey;
+	private 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;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@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 ;)
+	}
+}

+ 29 - 29
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/L2LoginServerPacket.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/L2LoginServerPacket.java

@@ -1,29 +1,29 @@
-/*
- * 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.l2jserver.loginserver.serverpackets;
-
-
-import org.mmocore.network.SendablePacket;
-
-import com.l2jserver.loginserver.L2LoginClient;
-
-/**
- *
- * @author  KenM
- */
-public abstract class L2LoginServerPacket extends SendablePacket<L2LoginClient>
-{
-	
-}
+/*
+ * 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.l2jserver.loginserver.network.serverpackets;
+
+
+import org.mmocore.network.SendablePacket;
+
+import com.l2jserver.loginserver.network.L2LoginClient;
+
+/**
+ *
+ * @author  KenM
+ */
+public abstract class L2LoginServerPacket extends SendablePacket<L2LoginClient>
+{
+	
+}

+ 95 - 95
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/LoginFail.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/LoginFail.java

@@ -1,95 +1,95 @@
-/*
- * 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.l2jserver.loginserver.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 LoginFailReason _reason;
-	
-	
-	public LoginFail(LoginFailReason reason)
-	{
-		_reason = reason;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@Override
-	protected void write()
-	{
-		writeC(0x01);
-		writeC(_reason.getCode());
-	}
-}
+/*
+ * 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.l2jserver.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 LoginFailReason _reason;
+	
+	
+	public LoginFail(LoginFailReason reason)
+	{
+		_reason = reason;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@Override
+	protected void write()
+	{
+		writeC(0x01);
+		writeC(_reason.getCode());
+	}
+}

+ 57 - 57
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/LoginOk.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/LoginOk.java

@@ -1,57 +1,57 @@
-/*
- * 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.l2jserver.loginserver.serverpackets;
-
-import com.l2jserver.loginserver.SessionKey;
-
-/**
- * Format: dddddddd
- * f: the session key
- * d: ?
- * d: ?
- * d: ?
- * d: ?
- * d: ?
- * d: ?
- * b: 16 bytes - unknown
- */
-public final class LoginOk extends L2LoginServerPacket
-{
-	private int _loginOk1, _loginOk2;
-	
-	public LoginOk(SessionKey sessionKey)
-	{
-		_loginOk1 = sessionKey.loginOkID1;
-		_loginOk2 = sessionKey.loginOkID2;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@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]);
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.serverpackets;
+
+import com.l2jserver.loginserver.SessionKey;
+
+/**
+ * Format: dddddddd
+ * f: the session key
+ * d: ?
+ * d: ?
+ * d: ?
+ * d: ?
+ * d: ?
+ * d: ?
+ * b: 16 bytes - unknown
+ */
+public final class LoginOk extends L2LoginServerPacket
+{
+	private int _loginOk1, _loginOk2;
+	
+	public LoginOk(SessionKey sessionKey)
+	{
+		_loginOk1 = sessionKey.loginOkID1;
+		_loginOk2 = sessionKey.loginOkID2;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@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]);
+	}
+}

+ 96 - 96
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/PlayFail.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/PlayFail.java

@@ -1,96 +1,96 @@
-/*
- * 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.l2jserver.loginserver.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;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@Override
-	protected void write()
-	{
-		writeC(0x06);
-		writeC(_reason.getCode());
-	}
-}
+/*
+ * 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.l2jserver.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;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@Override
+	protected void write()
+	{
+		writeC(0x06);
+		writeC(_reason.getCode());
+	}
+}

+ 42 - 42
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/PlayOk.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/PlayOk.java

@@ -1,42 +1,42 @@
-/*
- * 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.l2jserver.loginserver.serverpackets;
-
-import com.l2jserver.loginserver.SessionKey;
-
-/**
- *
- */
-public final class PlayOk extends L2LoginServerPacket
-{
-	private int _playOk1, _playOk2;
-	
-	public PlayOk(SessionKey sessionKey)
-	{
-		_playOk1 = sessionKey.playOkID1;
-		_playOk2 = sessionKey.playOkID2;
-	}
-	
-	/**
-	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
-	 */
-	@Override
-	protected void write()
-	{
-		writeC(0x07);
-		writeD(_playOk1);
-		writeD(_playOk2);
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.serverpackets;
+
+import com.l2jserver.loginserver.SessionKey;
+
+/**
+ *
+ */
+public final class PlayOk extends L2LoginServerPacket
+{
+	private int _playOk1, _playOk2;
+	
+	public PlayOk(SessionKey sessionKey)
+	{
+		_playOk1 = sessionKey.playOkID1;
+		_playOk2 = sessionKey.playOkID2;
+	}
+	
+	/**
+	 * @see com.l2jserver.mmocore.network.SendablePacket#write()
+	 */
+	@Override
+	protected void write()
+	{
+		writeC(0x07);
+		writeD(_playOk1);
+		writeD(_playOk2);
+	}
+}

+ 160 - 160
L2J_Server_BETA/java/com/l2jserver/loginserver/serverpackets/ServerList.java → L2J_Server_BETA/java/com/l2jserver/loginserver/network/serverpackets/ServerList.java

@@ -1,160 +1,160 @@
-/*
- * 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.l2jserver.loginserver.serverpackets;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import com.l2jserver.loginserver.GameServerTable;
-import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
-import com.l2jserver.loginserver.L2LoginClient;
-import com.l2jserver.loginserver.gameserverpackets.ServerStatus;
-
-/**
- * ServerList
- * 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: 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 final class ServerList extends L2LoginServerPacket
-{
-	private List<ServerData> _servers;
-	private int _lastServer;
-	private Map<Integer, Integer> _charsOnServers;
-	private 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)
-			{
-				e.printStackTrace();
-				_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<ServerData>(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);
-	}
-}
+/*
+ * 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.l2jserver.loginserver.network.serverpackets;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
+import com.l2jserver.loginserver.network.L2LoginClient;
+import com.l2jserver.loginserver.network.gameserverpackets.ServerStatus;
+
+/**
+ * ServerList
+ * 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: 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 final class ServerList extends L2LoginServerPacket
+{
+	private List<ServerData> _servers;
+	private int _lastServer;
+	private Map<Integer, Integer> _charsOnServers;
+	private 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)
+			{
+				e.printStackTrace();
+				_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<ServerData>(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);
+	}
+}

+ 0 - 4
L2J_Server_BETA/java/config/General.properties

@@ -888,10 +888,6 @@ Developer = False
 # Default: False
 AcceptGeoeditorConn = False
 
-# If True the server will be a test server (listed by test server clients only).
-# Default: False
-TestServer = False
-
 # Don't load Handlers
 # Default: False
 AltDevNoHandlers = False

+ 57 - 0
L2J_Server_BETA/java/config/email.properties

@@ -0,0 +1,57 @@
+# ---------------------------------------------------------------------------
+# Email Settings
+# ---------------------------------------------------------------------------
+# The defaults are set to be retail-like. If you modify any of these settings your server will deviate from being retail-like.
+# Warning: 
+# Please take extreme caution when changing anything. Also please understand what you are changing before you do so on a live server.
+# ---------------------------------------------------------------------------
+# Server Information
+# ---------------------------------------------------------------------------
+
+# Server Name
+# Default: Unconfigured L2J Server
+ServerInfoName = Unconfigured L2J Server
+
+# Contact Address
+# Default: info@unconfl2j.com
+ServerInfoAddress = info@myl2jserver.com
+
+# ---------------------------------------------------------------------------
+# E-mail System Settings
+# ---------------------------------------------------------------------------
+
+# Enable Email System
+# Default: False
+EmailSystemEnabled = True
+
+# Mail Server Host
+# Default: smtp.gmail.com
+SmtpServerHost = smtp.gmail.com
+
+# Mail Server Port
+# Default: 465
+SmtpServerPort = 465
+
+# Auth SMTP
+# Default: True
+SmtpAuthRequired = True
+
+# Mail Factory
+# Default: javax.net.ssl.SSLSocketFactory
+SmtpFactory = javax.net.ssl.SSLSocketFactory
+
+# Mail Factory Callback
+# Default: False
+SmtpFactoryCallback = False
+
+# Mail Server Auth - Username
+# Default: exampleuser
+SmtpUsername = user@gmail.com
+
+# Mail Server Auth - Password
+# Default: examplepass
+SmtpPassword = password
+
+# Mail Address
+# Default: None
+EmailSystemAddress = noreply@myl2jserver.com

+ 25 - 0
L2J_Server_BETA/java/config/security.properties

@@ -0,0 +1,25 @@
+# ---------------------------------------------------------------------------
+# Security Settings
+# ---------------------------------------------------------------------------
+# The defaults are set to be retail-like. If you modify any of these settings your server will deviate from being retail-like.
+# Warning: 
+# Please take extreme caution when changing anything. Also please understand what you are changing before you do so on a live server.
+# ---------------------------------------------------------------------------
+# Secondary Auth Settings
+# ---------------------------------------------------------------------------
+
+# Enable Secondary Authentication on Character Select
+# Default: False
+SecondAuthEnabled = False
+
+# Max Attempts for Second Auth Password
+# Default: 5
+SecondAuthMaxAttempts = 5
+
+# Ban time if user reach SecondAuthMaxAttempts (in minutes)
+# Default: 480
+SecondAuthBanTime = 480
+
+# Password Recovery Link
+# Default: http://www.example.com/l2j/charPassRec.php
+SecondAuthRecoveryLink = http://www.example.com/l2j/charPassRec.php

BIN
L2J_Server_BETA/lib/mail.jar


+ 337 - 0
L2J_Server_BETA/lib/mail_LICENSE.txt

@@ -0,0 +1,337 @@
+Oracle Corporation ("ORACLE") ENTITLEMENT for SOFTWARE
+
+Licensee/Company: Entity receiving Software.
+
+Effective Date: Date of delivery of the Software to You.
+
+Software: JavaMail 1.4.4
+
+License Term:  Perpetual (subject to termination under the SLA).
+
+Licensed Unit: Software Copy.
+
+Licensed unit Count: Unlimited.
+
+Permitted Uses: 
+
+1. You may reproduce and use the Software for Your own Individual,
+Commercial and Research and Instructional Use only for the purposes of
+designing, developing, testing, and running Your applets and
+applications ("Programs").
+
+2. Subject to the terms and conditions of this Agreement and
+restrictions and exceptions set forth in the Software's documentation,
+You may reproduce and distribute portions of Software identified as a
+redistributable in the documentation (each a "Redistributable"),
+provided that You comply with the following (note that You may be
+entitled to reproduce and distribute other portions of the Software not
+defined in the documentation as a Redistributable under certain other
+licenses as described in the THIRDPARTYLICENSEREADME, if applicable):
+
+(a) You distribute Redistributable complete and unmodified and only
+bundled as part of Your Programs,
+
+(b) Your Programs add significant and primary functionality to the
+Redistributable,
+
+(c) You distribute Redistributable for the sole purpose of running Your
+Programs,
+
+(d) You do not distribute additional software intended to replace any
+component(s) of the Redistributable,
+
+(e) You do not remove or alter any proprietary legends or notices
+contained in or on the Redistributable.
+
+(f) You only distribute the Redistributable subject to a license
+agreement that protects Oracle's interests consistent with the terms
+contained in this Agreement, and
+
+(g) You agree to defend and indemnify Oracle and its licensors from and
+against any damages, costs, liabilities, settlement amounts and/or
+expenses  (including attorneys' fees) incurred in connection with any
+claim, lawsuit or action by any third party that arises or results from
+the use or distribution of any and all Programs and/or
+Redistributable.
+
+3. Java Technology Restrictions.  You may not create, modify, or change
+the behavior of, or authorize Your licensees to create, modify, or
+change the behavior of, classes, interfaces, or subpackages that are in
+any way identified as "java", "javax", "sun" or similar convention as
+specified by Oracle in any naming convention designation.
+
+4. No Diagnostic, Maintenance, Repair or Technical Support Services.
+The scope of Your license does not include any right, express or
+implied, (i) to access, copy, distribute, display or use the Software
+to provide diagnostic, maintenance, repair or technical support
+services for Oracle software or Oracle hardware on behalf of any third party
+for Your direct or indirect commercial gain or advantage, without Oracle's
+prior written authorization, or (ii) for any third party to access,
+copy, distribute, display or use the Software to provide diagnostic,
+maintenance, repair or technical support services for Oracle software or
+Oracle hardware on Your behalf for such party's direct or indirect
+commercial gain or advantage, without Oracle's prior written
+authorization. The limitations set forth in this paragraph apply to any
+and all error corrections, patches, updates, and upgrades to the
+Software You may receive, access, download or otherwise obtain from
+Oracle.
+
+5. Records and Documentation.  During the term of the SLA and
+Entitlement, and for a period of three (3) years thereafter, You agree
+to keep proper records and documentation of Your compliance with the
+SLA and Entitlement. Upon Oracle's reasonable request, You will provide
+copies of such records and documentation to Oracle for the purpose of
+confirming Your compliance with the terms and conditions of the SLA and
+Entitlement. This section will survive any termination of the SLA and
+Entitlement. You may terminate this SLA and Entitlement at any time by
+destroying all copies of the Software in which case the obligations set
+forth in Section 7 of the SLA shall apply.
+
+
+Oracle Corporation ("ORACLE")
+SOFTWARE LICENSE AGREEMENT
+
+READ THE TERMS OF THIS AGREEMENT ("AGREEMENT") CAREFULLY BEFORE OPENING
+SOFTWARE MEDIA PACKAGE. BY OPENING SOFTWARE MEDIA PACKAGE, YOU AGREE TO
+THE TERMS OF THIS AGREEMENT. IF YOU ARE ACCESSING SOFTWARE
+ELECTRONICALLY, INDICATE YOUR ACCEPTANCE OF THESE TERMS BY SELECTING
+THE "ACCEPT" BUTTON AT THE END OF THIS AGREEMENT. IF YOU DO NOT AGREE
+TO ALL OF THE TERMS, PROMPTLY RETURN THE UNUSED SOFTWARE TO YOUR PLACE
+OF PURCHASE FOR A REFUND OR, IF SOFTWARE IS ACCESSED ELECTRONICALLY,
+SELECT THE "DECLINE" (OR "EXIT") BUTTON AT THE END OF THIS AGREEMENT.
+IF YOU HAVE SEPARATELY AGREED TO LICENSE TERMS ("MASTER TERMS") FOR
+YOUR LICENSE TO THIS SOFTWARE, THEN SECTIONS 1-6 OF THIS AGREEMENT
+("SUPPLEMENTAL LICENSE TERMS") SHALL SUPPLEMENT AND SUPERSEDE THE
+MASTER TERMS IN RELATION TO THIS SOFTWARE.
+
+1.	Definitions.
+
+(a)     "Entitlement" means the collective set of applicable documents
+authorized by Oracle evidencing your obligation to pay associated fees (if
+any) for the license, associated Services, and the authorized scope of
+use of Software under this Agreement.
+
+(b)     "Licensed Unit" means the unit of measure by which your use of
+Software and/or Service is licensed, as described in your Entitlement.
+
+(c)     "Permitted Use" means the licensed Software use(s) authorized
+in this Agreement as specified in your Entitlement. The Permitted Use
+for any bundled Oracle software not specified in your Entitlement will be
+evaluation use as provided in Section 3.
+
+(d)     "Service" means the service(s) that Oracle or its delegate will
+provide, if any, as selected in your Entitlement and as further
+described in the applicable service listings at
+www.sun.com/service/servicelist.
+
+(e)     "Software" means the Oracle software described in your
+Entitlement. Also, certain software may be included for evaluation use
+under Section 3.
+
+(f)     "You" and "Your" means the individual or legal entity specified
+in the Entitlement, or for evaluation purposes, the entity performing
+the evaluation.
+
+2.      License Grant and Entitlement.
+
+Subject to the terms of your Entitlement, Oracle grants you a
+nonexclusive, nontransferable limited license to use Software for its
+Permitted Use for the license term. Your Entitlement will specify (a)
+Software licensed, (b) the Permitted Use, (c) the license term, and (d)
+the Licensed Units.
+
+Additionally, if your Entitlement includes Services, then it will also
+specify the (e) Service and (f) service term.
+
+If your rights to Software or Services are limited in duration and the
+date such rights begin is other than the purchase date, your
+Entitlement will provide that beginning date(s).
+
+The Entitlement may be delivered to you in various ways depending on
+the manner in which you obtain Software and Services, for example, the
+Entitlement may be provided in your receipt, invoice or your contract
+with Oracle or authorized Oracle reseller. It may also be in electronic
+format if you download Software.
+
+3.      Permitted Use.
+
+As selected in your Entitlement, one or more of the following Permitted
+Uses will apply to your use of Software. Unless you have an Entitlement
+that expressly permits it, you may not use Software for any of the
+other Permitted Uses. If you don't have an Entitlement, or if your
+Entitlement doesn't cover additional software delivered to you, then
+such software is for your Evaluation Use.
+
+(a) Evaluation Use. You may evaluate Software internally for a period
+of 90 days from your first use.
+
+(b) Research and Instructional Use. You may use Software internally to
+design, develop and test, and also to provide instruction on such
+uses.
+
+(c) Individual Use. You may use Software internally for personal,
+individual use.
+
+(d) Commercial Use. You may use Software internally for your own
+commercial purposes.
+
+(e) Service Provider Use. You may make Software functionality
+accessible (but not by providing Software itself or through outsourcing
+services) to your end users in an extranet deployment, but not to your
+affiliated companies or to government agencies.
+
+4.      Licensed Units.
+
+Your Permitted Use is limited to the number of Licensed Units stated in
+your Entitlement. If you require additional Licensed Units, you will
+need additional Entitlement(s).
+
+5.      Restrictions.
+
+(a) The copies of Software provided to you under this Agreement are
+licensed, not sold, to you by Oracle. Oracle reserves all rights not
+expressly granted. (b) You may make a single archival copy of Software,
+but otherwise may not copy, modify, or distribute Software. However if
+the Oracle documentation accompanying Software lists specific portions of
+Software, such as header files, class libraries, reference source code,
+and/or redistributable files, that may be handled differently, you may
+do so only as provided in the Oracle documentation. (c) You may not rent,
+lease, lend or encumber Software. (d) Unless enforcement is prohibited
+by applicable law, you may not decompile, or reverse engineer Software.
+(e) The terms and conditions of this Agreement will apply to any
+Software updates, provided to you at Oracle's discretion, that replace
+and/or supplement the original Software, unless such update contains a
+separate license. (f) You may not publish or provide the results of any
+benchmark or comparison tests run on Software to any third party
+without the prior written consent of Oracle. (g) Software is confidential
+and copyrighted. (h) Unless otherwise specified, if Software is
+delivered with embedded or bundled software that enables functionality
+of Software, you may not use such software on a stand-alone basis or
+use any portion of such software to interoperate with any program(s)
+other than Software. (i) Software may contain programs that perform
+automated collection of system data and/or automated software updating
+services. System data collected through such programs may be used by
+Oracle, its subcontractors, and its service delivery partners for the
+purpose of providing you with remote system services and/or improving
+Oracle's software and systems. (j) Software is not designed, licensed or
+intended for use in the design, construction, operation or maintenance
+of any nuclear facility and Oracle and its licensors disclaim any express
+or implied warranty of fitness for such uses. (k) No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Oracle or its licensors is granted under this Agreement.
+
+6.      Java Compatibility and Open Source.
+
+Software may contain Java technology. You may not create additional
+classes to, or modifications of, the Java technology, except under
+compatibility requirements available under a separate agreement
+available at www.java.net.
+
+Oracle supports and benefits from the global community of open source
+developers, and thanks the community for its important contributions
+and open standards-based technology, which Oracle has adopted into many of
+its products.
+
+Please note that portions of Software may be provided with notices and
+open source licenses from such communities and third parties that
+govern the use of those portions, and any licenses granted hereunder do
+not alter any rights and obligations you may have under such open
+source licenses, however, the disclaimer of warranty and limitation of
+liability provisions in this Agreement will apply to all Software in
+this distribution.
+
+7.      Term and Termination.
+
+The license and service term are set forth in your Entitlement(s). Your
+rights under this Agreement will terminate immediately without notice
+from Oracle if you materially breach it or take any action in derogation
+of Oracle's and/or its licensors' rights to Software. Oracle may terminate
+this Agreement should any Software become, or in Oracle's reasonable
+opinion likely to become, the subject of a claim of intellectual
+property infringement or trade secret misappropriation. Upon
+termination, you will cease use of, and destroy, Software and confirm
+compliance in writing to Oracle. Sections 1, 5, 6, 7, and 9-15 will
+survive termination of the Agreement.
+
+8.      Limited Warranty.
+
+Oracle warrants to you that for a period of 90 days from the date of
+purchase, as evidenced by a copy of the receipt, the media on which
+Software is furnished (if any) will be free of defects in materials and
+workmanship under normal use. Except for the foregoing, Software is
+provided "AS IS". Your exclusive remedy and Oracle's entire liability
+under this limited warranty will be at Oracle's option to replace Software
+media or refund the fee paid for Software. Some states do not allow
+limitations on certain implied warranties, so the above may not apply
+to you. This limited warranty gives you specific legal rights. You may
+have others, which vary from state to state.
+
+9.      Disclaimer of Warranty.
+
+UNLESS SPECIFIED IN THIS AGREEMENT, ALL EXPRESS OR IMPLIED CONDITIONS,
+REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT
+ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS ARE HELD TO
+BE LEGALLY INVALID.
+
+10.     Limitation of Liability.
+
+TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ORACLE OR ITS
+LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES,
+HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR
+RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF ORACLE HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will Oracle's
+liability to you, whether in contract, tort (including negligence), or
+otherwise, exceed the amount paid by you for Software under this
+Agreement. The foregoing limitations will apply even if the above
+stated warranty fails of its essential purpose. Some states do not
+allow the exclusion of incidental or consequential damages, so some of
+the terms above may not be applicable to you.
+
+11.     Export Regulations.
+
+All Software, documents, technical data, and any other materials
+delivered under this Agreement are subject to U.S. export control laws
+and may be subject to export or import regulations in other countries.
+You agree to comply strictly with these laws and regulations and
+acknowledge that you have the responsibility to obtain any licenses to
+export, re-export, or import as may be required after delivery to you.
+
+12.     U.S. Government Restricted Rights.
+
+If Software is being acquired by or on behalf of the U.S. Government or
+by a U.S. Government prime contractor or subcontractor (at any tier),
+then the Government's rights in Software and accompanying documentation
+will be only as set forth in this Agreement; this is in accordance with
+48 CFR 227.7201 through 227.7202-4 (for Department of Defense (DOD)
+acquisitions) and with 48 CFR 2.101 and 12.212 (for non-DOD
+acquisitions).
+
+13.     Governing Law.
+
+Any action related to this Agreement will be governed by California law
+and controlling U.S. federal law. No choice of law rules of any
+jurisdiction will apply.
+
+14.     Severability.
+
+If any provision of this Agreement is held to be unenforceable, this
+Agreement will remain in effect with the provision omitted, unless
+omission would frustrate the intent of the parties, in which case this
+Agreement will immediately terminate.
+
+15.     Integration.
+
+This Agreement, including any terms contained in your Entitlement, is
+the entire agreement between you and Oracle relating to its subject
+matter. It supersedes all prior or contemporaneous oral or written
+communications, proposals, representations and warranties and prevails
+over any conflicting or additional terms of any quote, order,
+acknowledgment, or other communication between the parties relating to
+its subject matter during the term of this Agreement. No modification
+of this Agreement will be binding, unless in writing and signed by an
+authorized representative of each party.
+
+For inquiries please contact: Oracle Corporation, 500 Oracle Parkway,
+Redwood Shores, California 94065, USA.

BIN
L2J_Server_BETA/lib/mailapi.jar


BIN
L2J_Server_BETA/lib/smtp.jar