Example #1
0
        public static void AuthSessionRequest(RealmClient client, RealmPacketIn packet)
        {
            packet.SkipBytes(8);
            string                   accName      = packet.ReadString();
            uint                     clientSeed   = packet.ReadUInt32();
            BigInteger               clientDigest = packet.ReadBigInteger(20);
            AuthenticationInfo       authInfo;
            SecureRemotePassword     srp;
            AuthenticationErrorCodes errorCode = AuthenticationErrorCodes.AuthFailed;

            client.Account = new Account(client, accName);

            if (!client.Account.Initialize())
            {
                errorCode = AuthenticationErrorCodes.UnknownAccount;

                goto sendErrorReply;
            }

            if (client.Server.RequestAuthenticationInfo(accName, out authInfo))
            {
                srp = new SecureRemotePassword(accName, authInfo.Verifier, new BigInteger(authInfo.Salt, 32));

                client.Account.SessionKey = authInfo.SessionKey;
                client.SystemInfo         = SystemInformation.Deserialize(authInfo.SystemInformation);
            }
            else
            {
                goto sendErrorReply;
            }

            BigInteger clientVerifier = srp.Hash(srp.Username, new byte[4], clientSeed, client.Server.AuthSeed,
                                                 client.Account.SessionKey);

            client.IsEncrypted = true;             // all packets from here on are encrypted, including the AuthSessionReplys

            if (clientVerifier == clientDigest)
            {
                AddonHandler.ReadAddOns(client, packet);

                client.Server.LoginAccount(client.Account.Username);

                if (AuthQueue.QueuedClients > 0 ||
                    client.Server.NumberOfClients > client.Server.Config.ServerCapacity)
                {
                    AuthQueue.EnqueueClient(client);

                    return;
                }

                SendAuthSessionSuccess(client);

                return;
            }
            else
            {
                goto sendErrorReply;
            }

sendErrorReply:
            SendAuthSessionErrorReply(client, errorCode);

            client.Disconnect();
        }
Example #2
0
		public static void AuthSessionRequest(RealmClient client, RealmPacketIn packet)
		{
			packet.SkipBytes(8);
			string accName = packet.ReadString();
			uint clientSeed = packet.ReadUInt32();
			BigInteger clientDigest = packet.ReadBigInteger(20);
			AuthenticationInfo authInfo;
			SecureRemotePassword srp;
			AuthenticationErrorCodes errorCode = AuthenticationErrorCodes.AuthFailed;

			client.Account = new Account(client, accName);

			if (!client.Account.Initialize())
			{
				errorCode = AuthenticationErrorCodes.UnknownAccount;

				goto sendErrorReply;
			}

			if (client.Server.RequestAuthenticationInfo(accName, out authInfo))
			{
				srp = new SecureRemotePassword(accName, authInfo.Verifier, new BigInteger(authInfo.Salt, 32));

				client.Account.SessionKey = authInfo.SessionKey;
				client.SystemInfo = SystemInformation.Deserialize(authInfo.SystemInformation);
			}
			else
			{
				goto sendErrorReply;
			}

			BigInteger clientVerifier = srp.Hash(srp.Username, new byte[4], clientSeed, client.Server.AuthSeed,
													client.Account.SessionKey);

			client.IsEncrypted = true; // all packets from here on are encrypted, including the AuthSessionReplys

			if (clientVerifier == clientDigest)
			{
                AddonHandler.ReadAddOns(client, packet);

				client.Server.LoginAccount(client.Account.Username);

				if (AuthQueue.QueuedClients > 0 ||
					client.Server.NumberOfClients > client.Server.Config.ServerCapacity)
				{
					AuthQueue.EnqueueClient(client);

					return;
				}

				SendAuthSessionSuccess(client);

				return;
			}
			else
			{
				goto sendErrorReply;
			}

		sendErrorReply:
			SendAuthSessionErrorReply(client, errorCode);

			client.Disconnect();
		}
Example #3
0
        public static void CharacterRenameRequest(RealmClient client, RealmPacketIn packet)
        {
            if (client.Account == null)
            {
                return;
            }

            CharacterRecord cr = null;

            EntityId guid    = packet.ReadEntityId();
            string   newName = packet.ReadString();

            if (!client.Account.Characters.ContainsKey(guid))
            {
                s_log.Error(Resources.IllegalRenameAttempt, guid.ToString(), RealmClient.GetInfo(client));
                return;
            }
            else
            {
                cr = client.Account.Characters[guid];

                if (((CharEnumFlags)cr.CharacterFlags & CharEnumFlags.NeedsRename) != CharEnumFlags.NeedsRename)
                {
                    // their character isn't flagged to be renamed, what do they think they're doing? ;)
                    client.Disconnect();
                    return;
                }
            }

            if (newName.Length == 0)
            {
                SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_INVALID);
                return;
            }

            if (Character.Exists(newName))
            {
                SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_USED);
                return;
            }

            if (newName.Length < 3)
            {
                SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MIN_3);
                return;
            }

            if (newName.Length > 12)
            {
                SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MAX_12);
                return;
            }

            if (Character.DoesNameViolate(newName))
            {
                SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_PROFANITY);
                return;
            }

            s_log.Debug(Resources.RenamingCharacter, cr.Name, newName);

            cr.Name = newName.ToCapitalizedString();
            cr.UpdateAndFlush();

            client.Account.ReloadCharacters();

            SendCharacterRenameSuccess(client, guid, newName);
        }
Example #4
0
		public static void CharacterRenameRequest(RealmClient client, RealmPacketIn packet)
		{
			if (client.Account == null)
			{
				return;
			}

			CharacterRecord cr = null;

			EntityId guid = packet.ReadEntityId();
			string newName = packet.ReadString();

			if (!client.Account.Characters.ContainsKey(guid))
			{
				s_log.Error(Resources.IllegalRenameAttempt, guid.ToString(), RealmClient.GetInfo(client));
				return;
			}
			else
			{
				cr = client.Account.Characters[guid];

				if (((CharEnumFlags)cr.CharacterFlags & CharEnumFlags.NeedsRename) != CharEnumFlags.NeedsRename)
				{
					// their character isn't flagged to be renamed, what do they think they're doing? ;)
					client.Disconnect();
					return;
				}
			}

			if (newName.Length == 0)
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_INVALID);
				return;
			}

			if (Character.Exists(newName))
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_USED);
				return;
			}

			if (newName.Length < 3)
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MIN_3);
				return;
			}

			if (newName.Length > 12)
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MAX_12);
				return;
			}

			if (Character.DoesNameViolate(newName))
			{
				SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_PROFANITY);
				return;
			}

			s_log.Debug(Resources.RenamingCharacter, cr.Name, newName);

			cr.Name = newName.ToCapitalizedString();
			cr.UpdateAndFlush();

			client.Account.ReloadCharacters();

			SendCharacterRenameSuccess(client, guid, newName);
		}