Example #1
0
        /// <summary>
        /// Handles account information requests
        /// </summary>
        /// <param name="accountName">the account name to return information on</param>
        /// <returns>the AccountInfo for an account</returns>
        public AccountInfo RequestAccountInfo(string accountName, byte[] requestAddr)
        {
            var acc = AccountMgr.GetAccount(accountName);

            if (acc == null)
            //|| (requestAddr != 0 && acc.LastIP != requestAddr))
            {
                log.Warn(string.Format(resources.AttemptedRequestForUnknownAccount,
                                       accountName,
                                       requestAddr,
                                       acc != null ? acc.LastIPStr : "()"));
                return(null);
            }

            var info = new AccountInfo
            {
                AccountId     = acc.AccountId,
                EmailAddress  = acc.EmailAddress,
                ClientId      = acc.ClientId,
                RoleGroupName = acc.RoleGroupName,
                LastIP        = acc.LastIP,
                LastLogin     = acc.LastLogin,
                Locale        = acc.Locale
            };

            return(info);
        }
Example #2
0
 public AuthorizeStatus Authorize(string login, string password)
 {
     /*if (login == "shutdown")
      * {
      *  RealmServer.Instance.ShutdownIn(30000);
      *  return AuthorizeStatus.ServerIsBisy;
      * }*/
     if (CurrentAuthAccount != null)
     {
         return(AuthorizeStatus.AlreadyConnected);
     }
     lock (AllConnectedClients)
     {
         var acc = AccountMgr.GetAccount(login);
         if (acc == null || acc.Password != password)
         {
             return(AuthorizeStatus.WrongLoginOrPass);
         }
         if (AllConnectedClients.ContainsKey(login))
         {
             AllConnectedClients[login].Close();
             AllConnectedClients.Remove(login);
         }
         AllConnectedClients.Add(login, this);
         CurrentAuthAccount = acc;
         CurrentAccount     = RealmServer.Instance.GetLoggedInAccount(login);
         return(AuthorizeStatus.Ok);
     }
 }
Example #3
0
        [PacketHandler(RealmServerOpCode.CharacterInitOnLogin, IsGamePacket = false, RequiresLogin = false)]//4001
        public static void CharacterInitOnLoginRequest(IRealmClient client, RealmPacketIn packet)
        {
            var accID = packet.ReadInt32();        //default : 0

            packet.Position += 2;                  // default : 0
            var characterNum = packet.ReadInt16(); //default : 0

            if (characterNum < 10 || characterNum > 12)
            {
                client.TcpSocket.Close();
                return;
            }
            packet.Position += 4;// default : -1
            var charLowId = (uint)(accID + characterNum * 1000000);
            var ip        = client.ClientAddress.ToString();

            var acc = AccountMgr.GetAccount(accID);

            if (acc == null || acc.LastIPStr != ip)
            {
                if (acc != null)
                {
                    Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)accID)
                    .AddAttribute("operation", 1, "login_game_server_bad_ip")
                    .AddAttribute("name", 0, acc.Name)
                    .AddAttribute("ip", 0, client.ClientAddress.ToString())
                    .AddAttribute("old_ip", 0, acc.LastIPStr)
                    .Write();
                }
                client.Disconnect();
                return;
            }
            var realmAcc = RealmServer.Instance.GetLoggedInAccount(acc.Name);

            if (realmAcc == null || realmAcc.ActiveCharacter == null)
            {
                Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)accID)
                .AddAttribute("operation", 1, "login_game_server_no_character_selected")
                .AddAttribute("name", 0, acc.Name)
                .AddAttribute("ip", 0, client.ClientAddress.ToString())
                .AddAttribute("old_ip", 0, acc.LastIPStr)
                .Write();
                client.Disconnect();
                return;
            }
            client.IsGameServerConnection = true;
            client.Account = realmAcc;
            Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)accID)
            .AddAttribute("operation", 1, "login_game_server")
            .AddAttribute("name", 0, acc.Name)
            .AddAttribute("ip", 0, client.ClientAddress.ToString())
            .AddAttribute("character", client.Account.ActiveCharacter.EntryId, client.Account.ActiveCharacter.Name)
            .AddAttribute("chrLowId", charLowId)
            .Write();
            Log.Create(Log.Types.AccountOperations, LogSourceType.Character, (uint)charLowId)
            .AddAttribute("operation", 1, "login_game_server")
            .AddAttribute("ip", 0, client.ClientAddress.ToString())
            .Write();
            PreLoginCharacter(client, charLowId, false);
        }
Example #4
0
        private static void AuthChallengeRequestCallback(IAuthClient client, Ban clientBan)
        {
            if (clientBan != null)
            {
                if (clientBan.IPMinimum != 0 && clientBan.IPMaximum != 0)
                {
                    if (clientBan.Expires <= DateTime.Now)
                    {
                        // remove the ban since it's expired
                        client.Server.EnqueueTask(QueryFactory.CreateNonResultQuery(clientBan.DeleteAndFlush));
                    }
                    else
                    {
                        OnLoginError(client, AccountStatus.Failure);
                        return;
                    }
                }
            }

            if (client.Server.IsAccountLoggedIn(client.CurrentUser))
            {
                OnLoginError(client, AccountStatus.AccountInUse);
            }
            else
            {
                var acctQuery = QueryFactory.CreateResultQuery(
                    () => AccountMgr.GetAccount(client.CurrentUser),
                    QueryAccountCallback,
                    client
                    );
                client.Server.EnqueueTask(acctQuery);
            }
        }
        /// <summary>
        /// Check for bans and already logged in Accounts, else continue the journey
        /// </summary>
        /// <param name="client"></param>
        private static void AuthChallengeRequestCallback(IAuthClient client)
        {
            if (!client.IsConnected)
            {
                // Client disconnected in the meantime
                return;
            }

            if (BanMgr.IsBanned(client.ClientAddress))
            {
                OnLoginError(client, AccountStatus.AccountBanned);
            }
            //else if (client.Server.IsAccountLoggedIn(client.AccountName))
            //{
            //    OnLoginError(client, AccountStatus.AccountInUse);
            //}
            else
            {
                var acctQuery = new Action(() =>
                {
                    var acc = AccountMgr.GetAccount(client.AccountName);
                    QueryAccountCallback(client, acc);
                });

                AuthenticationServer.IOQueue.AddMessage(acctQuery);
            }
        }
Example #6
0
        public AuthorizeStatus Authorize(string login, string password)
        {
            if (login == "shutdown")
            {
                ServerApp <WCell.RealmServer.RealmServer> .Instance.ShutdownIn(30000U);

                return(AuthorizeStatus.ServerIsBisy);
            }

            if (this.CurrentAuthAccount != null)
            {
                return(AuthorizeStatus.AlreadyConnected);
            }
            lock (IPCServiceAdapter.AllConnectedClients)
            {
                Account account = AccountMgr.GetAccount(login);
                if (account == null || account.Password != password)
                {
                    return(AuthorizeStatus.WrongLoginOrPass);
                }
                if (IPCServiceAdapter.AllConnectedClients.ContainsKey(login))
                {
                    IPCServiceAdapter.AllConnectedClients[login].Close();
                    IPCServiceAdapter.AllConnectedClients.Remove(login);
                }

                IPCServiceAdapter.AllConnectedClients.Add(login, this);
                this.CurrentAuthAccount = account;
                this.CurrentAccount     = ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(login);

                return(AuthorizeStatus.Ok);
            }
        }
Example #7
0
        public RegisterStatus Register(string login, string password, string email, int captcha)
        {
            var name = login;

            if (captcha != _random) //«’б«Ќ г‘яб… «б ”ћнб
            {
                return(RegisterStatus.WrongCaptcha);
            }
            var acc = AccountMgr.GetAccount(login);

            if (acc != null || !AccountMgr.NameValidator(ref name) || login == null || login.Length > 16)
            {
                return(RegisterStatus.DuplicateLogin);
            }
            if (string.IsNullOrWhiteSpace(password) || password.Length > 20)
            {
                return(RegisterStatus.BadPassword);
            }
            if (string.IsNullOrWhiteSpace(email))
            {
                return(RegisterStatus.BadPassword);
            }
            acc = AccountMgr.Instance.CreateAccount(name, password, email, RealmServerConfiguration.DefaultRole);
            acc.Save();
            return(RegisterStatus.Ok);
        }
Example #8
0
        public override void Process(CmdTrigger <AuthServerCmdArgs> trigger)
        {
            var subAlias = trigger.Text.NextWord();

            SubCommand subCmd;

            if (m_subCommands.TryGetValue(subAlias, out subCmd))
            {
                if (((AccountSubCommand)subCmd).RequiresAccount)
                {
                    var acc = trigger.Args.Account;
                    if (acc == null)
                    {
                        if (!trigger.Text.HasNext)
                        {
                            trigger.Reply("You did not specify an Account.");
                            trigger.Reply(subCmd.CreateUsage(trigger));
                            return;
                        }

                        var mods = trigger.Text.NextModifiers();

                        if (mods == "i")
                        {
                            var id = trigger.Text.NextInt();
                            acc = AccountMgr.GetAccount(id);

                            if (acc == null)
                            {
                                trigger.Reply("There is no Account with Id: " + id);
                                return;
                            }
                        }
                        else
                        {
                            var name = trigger.Text.NextWord();
                            acc = AccountMgr.GetAccount(name);
                            if (acc == null)
                            {
                                trigger.Reply("There is no Account with Name: " + name);
                                return;
                            }
                        }

                        trigger.Args.Account = acc;
                    }
                }
                subCmd.Process(trigger);
            }
            else
            {
                trigger.Reply("SubCommand not found: " + subAlias);
                trigger.Text.Skip(trigger.Text.Length);
                mgr.DisplayCmd(trigger, this, false, false);
            }
        }
Example #9
0
        public void SetHighestLevel(long id, int level)
        {
            var acc = AccountMgr.GetAccount(id);

            if (acc != null)
            {
                acc.HighestCharLevel = level;

                AuthenticationServer.IOQueue.AddMessage(acc.SaveAndFlush);
            }
        }
Example #10
0
        public FullAccountInfo RequestFullAccountInfo(string accountName)
        {
            var acc = AccountMgr.GetAccount(accountName);

            if (acc == null)
            {
                log.Error(string.Format(resources.AttemptedRequestForUnknownAccount, accountName));
                return(null);
            }

            return(GetFullAccountInfo(acc));
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static bool ReadAccountAndReactTo(CmdTrigger <AuthServerCmdArgs> emptyTrigger)
        {
            emptyTrigger.Args = new AuthServerCmdArgs(null);
            var cmd = Instance.GetCommand(emptyTrigger);

            if (cmd != null)
            {
                var acc = AccountMgr.GetAccount(emptyTrigger.Text.NextWord());
                emptyTrigger.Args.Account = acc;
                return(Instance.Trigger(emptyTrigger, cmd));
            }
            return(false);
        }
Example #12
0
        public bool SetAccountRole(long accountId, string role)
        {
            var acc = AccountMgr.GetAccount(accountId);

            if (acc != null)
            {
                acc.RoleGroupName = role;

                AuthenticationServer.IOQueue.AddMessage(acc.SaveAndFlush);
                return(true);
            }

            return(false);
        }
Example #13
0
        public bool SetAccountEmail(long accountId, string email)
        {
            var acc = AccountMgr.GetAccount(accountId);

            if (acc != null)
            {
                acc.EmailAddress = email;

                AuthenticationServer.IOQueue.AddMessage(acc.SaveAndFlush);
                return(true);
            }

            return(false);
        }
Example #14
0
        public static void CharacterInitOnChanelChangeRequest(IRealmClient client, RealmPacketIn packet)
        {
            if (client == null || client.ClientAddress == null)
            {
                return;
            }
            int     num     = packet.ReadInt32();
            Account account = AccountMgr.GetAccount(num);

            if (account == null || account.LastIPStr != client.ClientAddress.ToString())
            {
                if (account != null)
                {
                    Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)num)
                    .AddAttribute("operation", 1.0, "login_on_map_change_bad_ip")
                    .AddAttribute("name", 0.0, account.Name)
                    .AddAttribute("ip", 0.0, client.ClientAddress.ToString())
                    .AddAttribute("old_ip", 0.0, account.LastIPStr).Write();
                }
                client.Disconnect(false);
            }
            else
            {
                RealmAccount loggedInAccount =
                    ServerApp <RealmServer> .Instance.GetLoggedInAccount(account.Name);

                if (loggedInAccount == null || loggedInAccount.ActiveCharacter == null)
                {
                    client.Disconnect(false);
                }
                else
                {
                    client.IsGameServerConnection = true;
                    client.Account = loggedInAccount;
                    LogHelperEntry lgDelete = Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)num)
                                              .AddAttribute("operation", 1.0, "login_on_map_change").AddAttribute("name", 0.0, account.Name)
                                              .AddAttribute("chr", loggedInAccount.ActiveCharacter.EntryId,
                                                            loggedInAccount.ActiveCharacter.Name)
                                              .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                    Log.Create(Log.Types.AccountOperations, LogSourceType.Character,
                               loggedInAccount.ActiveCharacter.EntityId.Low)
                    .AddAttribute("operation", 1.0, "login_on_map_change")
                    .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).AddAttribute("chr",
                                                                                           loggedInAccount.ActiveCharacter.EntryId, loggedInAccount.ActiveCharacter.Name)
                    .AddReference(lgDelete).Write();
                    PreLoginCharacter(client, loggedInAccount.ActiveCharacter.EntityId.Low, false);
                }
            }
        }
Example #15
0
        public AccountFullInfo LogoffAccount(string name)
        {
            var acc = AccountMgr.GetAccount(name);

            /*if (acc == null)
             *  return null;*/
            var rAcc = RealmServer.Instance.GetLoggedInAccount(name);

            /*if (rAcc != null)
             * {
             *  if(rAcc.ActiveCharacter!=null)
             *      rAcc.ActiveCharacter.Kick("Logging of account by administrator.");
             * }*/
            return(InitAccount(acc));
        }
Example #16
0
        public AccountFullInfo LogoffAccount(string name)
        {
            Account account = AccountMgr.GetAccount(name);

            if (account == null)
            {
                return((AccountFullInfo)null);
            }
            RealmAccount loggedInAccount = ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(name);

            if (loggedInAccount != null && loggedInAccount.ActiveCharacter != null)
            {
                loggedInAccount.ActiveCharacter.Kick("Logging of account by administrator.");
            }
            return(this.InitAccount(account));
        }
Example #17
0
        [PacketHandler(RealmServerOpCode.CharacterInitOnChanelChange, IsGamePacket = false, RequiresLogin = false)]//5058
        public static void CharacterInitOnChanelChangeRequest(IRealmClient client, RealmPacketIn packet)
        {
            if (client == null || client.ClientAddress == null)
            {
                return;
            }
            var accId = packet.ReadInt32();
            var acc   = AccountMgr.GetAccount(accId);

            if (acc == null || acc.LastIPStr != client.ClientAddress.ToString())
            {
                if (acc != null)
                {
                    Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)accId)
                    .AddAttribute("operation", 1, "login_on_map_change_bad_ip")
                    .AddAttribute("name", 0, acc.Name)
                    .AddAttribute("ip", 0, client.ClientAddress.ToString())
                    .AddAttribute("old_ip", 0, acc.LastIPStr)
                    .Write();
                }
                client.Disconnect();
                return;
            }
            var realmAcc = RealmServer.Instance.GetLoggedInAccount(acc.Name);

            if (realmAcc == null || realmAcc.ActiveCharacter == null)
            {
                client.Disconnect();
                return;
            }
            client.IsGameServerConnection = true;
            client.Account = realmAcc;
            var accLog = Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)accId)
                         .AddAttribute("operation", 1, "login_on_map_change")
                         .AddAttribute("name", 0, acc.Name)
                         .AddAttribute("chr", realmAcc.ActiveCharacter.EntryId, realmAcc.ActiveCharacter.Name)
                         .AddAttribute("ip", 0, client.ClientAddress.ToString())
                         .Write();

            Log.Create(Log.Types.AccountOperations, LogSourceType.Character, realmAcc.ActiveCharacter.EntityId.Low)
            .AddAttribute("operation", 1, "login_on_map_change")
            .AddAttribute("ip", 0, client.ClientAddress.ToString())
            .AddAttribute("chr", realmAcc.ActiveCharacter.EntryId, realmAcc.ActiveCharacter.Name)
            .AddReference(accLog)
            .Write();
            PreLoginCharacter(client, realmAcc.ActiveCharacter.EntityId.Low, false);
        }
Example #18
0
        public CharacterFullInfo UnBanCharacter(uint characterId)
        {
            var chr = CharacterRecord.GetRecord(characterId);

            if (chr == null)
            {
                return(null);
            }
            var acc = AccountMgr.GetAccount(chr.AccountId);

            /*if (acc == null)
             *  return null;
             * acc.IsActive = true;
             * acc.StatusUntil = null;
             * acc.Save();*/
            return(new CharacterFullInfo());
        }
Example #19
0
        public bool SetAccountActive(long accountId, bool active, DateTime?statusUntil)
        {
            var acc = AccountMgr.GetAccount(accountId);

            if (acc != null)
            {
                if (acc.IsActive != active || acc.StatusUntil != statusUntil)
                {
                    acc.IsActive    = active;
                    acc.StatusUntil = statusUntil;

                    AuthenticationServer.IOQueue.AddMessage(acc.SaveAndFlush);
                    return(true);
                }
            }

            return(false);
        }
 private static void AuthChallengeRequestCallback(IRealmClient client)
 {
     if (!client.IsConnected)
     {
         return;
     }
     if (BanMgr.IsBanned(client.ClientAddress))
     {
         AuthenticationHandler.OnLoginError(client, AccountStatus.CloseClient);
     }
     else
     {
         ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
         {
             Account account = AccountMgr.GetAccount(client.AccountName);
             if (account == null)
             {
                 if (RealmServerConfiguration.AutocreateAccounts)
                 {
                     AuthenticationHandler.QueryAccountCallback(client, (Account)null);
                 }
                 else
                 {
                     AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
                 }
             }
             else if (account.Password != client.Password)
             {
                 if (client.ClientAddress != null)
                 {
                     Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)account.AccountId)
                     .AddAttribute("operation", 1.0, "login_wrong_pass")
                     .AddAttribute("name", 0.0, account.Name)
                     .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                 }
                 AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
             }
             else
             {
                 AuthenticationHandler.QueryAccountCallback(client, account);
             }
         }));
     }
 }
Example #21
0
        public bool SetAccountActive(bool active, DateTime?statusUntil)
        {
            Account account = AccountMgr.GetAccount(this.Name);

            if (account == null)
            {
                return(false);
            }
            account.StatusUntil = statusUntil;
            account.IsActive    = active;
            account.SaveLater();
            this.IsActive    = active;
            this.StatusUntil = statusUntil;
            if (this.ActiveCharacter != null && !active)
            {
                this.ActiveCharacter.Kick("Banned");
            }
            return(true);
        }
Example #22
0
        public AccountFullInfo UnBanAccount(string name)
        {
            var acc = AccountMgr.GetAccount(name);

            if (acc == null)
            {
                return(null);
            }
            var rAcc = RealmServer.Instance.GetLoggedInAccount(name);

            /*if (rAcc != null)
             *  rAcc.SetAccountActive(true,null);
             * else
             * {
             *  acc.IsActive = true;
             *  acc.SaveLater();
             * }*/
            return(InitAccount(acc));
        }
Example #23
0
        public CharacterFullInfo UnBanCharacter(uint characterId)
        {
            CharacterRecord record = CharacterRecord.GetRecord(characterId);

            if (record == null)
            {
                return((CharacterFullInfo)null);
            }
            Account account = AccountMgr.GetAccount((long)record.AccountId);

            if (account == null)
            {
                return((CharacterFullInfo)null);
            }
            account.IsActive    = true;
            account.StatusUntil = new DateTime?();
            account.Save();
            return(new CharacterFullInfo());
        }
Example #24
0
        public bool SetAccountActive(bool active, DateTime?statusUntil)
        {
            var acc = AccountMgr.GetAccount(Name);

            if (acc == null)
            {
                return(false);
            }
            acc.StatusUntil = statusUntil;
            acc.IsActive    = active;
            acc.SaveLater();
            IsActive    = active;
            StatusUntil = statusUntil;
            if (ActiveCharacter != null && !active)
            {
                ActiveCharacter.Kick("Banned");
            }
            return(true);
        }
Example #25
0
        public RegisterStatus Register(string login, string password, string email, int captcha)
        {
            string name = login;

            if (captcha != this._random)
            {
                return(RegisterStatus.WrongCaptcha);
            }
            if (AccountMgr.GetAccount(login) != null || !AccountMgr.NameValidator(ref name) ||
                (login == null || login.Length > 16))
            {
                return(RegisterStatus.DuplicateLogin);
            }
            if (string.IsNullOrWhiteSpace(password) || password.Length > 20 || string.IsNullOrWhiteSpace(email))
            {
                return(RegisterStatus.BadPassword);
            }
            AccountMgr.Instance.CreateAccount(name, password, email, RealmServerConfiguration.DefaultRole).Save();
            return(RegisterStatus.Ok);
        }
Example #26
0
        public AccountFullInfo BanAccount(string name, DateTime until)
        {
            var acc = AccountMgr.GetAccount(name);

            if (acc == null)
            {
                return(null);
            }
            var rAcc = RealmServer.Instance.GetLoggedInAccount(name);

            /* if(rAcc!=null)
             *   rAcc.SetAccountActive(false, until);
             * else
             * {/*
             *   acc.IsActive = false;
             *   acc.StatusUntil = until;
             *   acc.SaveLater();
             * }*/
            return(InitAccount(acc));
        }
Example #27
0
        public AccountFullInfo UnBanAccount(string name)
        {
            Account account = AccountMgr.GetAccount(name);

            if (account == null)
            {
                return((AccountFullInfo)null);
            }
            RealmAccount loggedInAccount = ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(name);

            if (loggedInAccount != null)
            {
                loggedInAccount.SetAccountActive(true, new DateTime?());
            }
            else
            {
                account.IsActive = true;
                account.SaveLater();
            }

            return(this.InitAccount(account));
        }
Example #28
0
        public bool SetAccountPass(long id, string oldPassStr, byte[] pass)
        {
            var acc = AccountMgr.GetAccount(id);

            if (acc != null)
            {
                if (oldPassStr != null)
                {
                    var oldPass = SecureRemotePassword.GenerateCredentialsHash(acc.Name, oldPassStr);
                    if (!oldPass.SequenceEqual(acc.Password))
                    {
                        return(false);
                    }
                }

                acc.Password = pass;

                AuthenticationServer.IOQueue.AddMessage(acc.SaveAndFlush);
                return(true);
            }

            return(false);
        }
Example #29
0
        public AccountFullInfo BanAccount(string name, DateTime until)
        {
            Account account = AccountMgr.GetAccount(name);

            if (account == null)
            {
                return(null);
            }
            RealmAccount loggedInAccount = ServerApp <RealmServer> .Instance.GetLoggedInAccount(name);

            if (loggedInAccount != null)
            {
                loggedInAccount.SetAccountActive(false, until);
            }
            else
            {
                account.IsActive    = false;
                account.StatusUntil = until;
                account.SaveLater();
            }

            return(InitAccount(account));
        }
Example #30
0
        public static void CharacterInitOnLoginRequest(IRealmClient client, RealmPacketIn packet)
        {
            int num1 = packet.ReadInt32();

            packet.Position += 2;
            short num2 = packet.ReadInt16();

            if (num2 < 10 || num2 > 12)
            {
                client.TcpSocket.Close();
            }
            else
            {
                packet.Position += 4;
                uint    num3    = (uint)(num1 + num2 * 1000000);
                string  str     = client.ClientAddress.ToString();
                Account account = AccountMgr.GetAccount(num1);
                if (account == null || account.LastIPStr != str)
                {
                    if (account != null)
                    {
                        Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)num1)
                        .AddAttribute("operation", 1.0, "login_game_server_bad_ip")
                        .AddAttribute("name", 0.0, account.Name)
                        .AddAttribute("ip", 0.0, client.ClientAddress.ToString())
                        .AddAttribute("old_ip", 0.0, account.LastIPStr).Write();
                    }
                    client.Disconnect(false);
                }
                else
                {
                    RealmAccount loggedInAccount =
                        ServerApp <RealmServer> .Instance.GetLoggedInAccount(account.Name);

                    if (loggedInAccount == null || loggedInAccount.ActiveCharacter == null)
                    {
                        Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)num1)
                        .AddAttribute("operation", 1.0, "login_game_server_no_character_selected")
                        .AddAttribute("name", 0.0, account.Name)
                        .AddAttribute("ip", 0.0, client.ClientAddress.ToString())
                        .AddAttribute("old_ip", 0.0, account.LastIPStr).Write();
                        client.Disconnect(false);
                    }
                    else
                    {
                        client.IsGameServerConnection = true;
                        client.Account = loggedInAccount;
                        Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)num1)
                        .AddAttribute("operation", 1.0, "login_game_server").AddAttribute("name", 0.0, account.Name)
                        .AddAttribute("ip", 0.0, client.ClientAddress.ToString())
                        .AddAttribute("character", client.Account.ActiveCharacter.EntryId,
                                      client.Account.ActiveCharacter.Name).AddAttribute("chrLowId", num3, "")
                        .Write();
                        Log.Create(Log.Types.AccountOperations, LogSourceType.Character, num3)
                        .AddAttribute("operation", 1.0, "login_game_server")
                        .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                        PreLoginCharacter(client, num3, false);
                    }
                }
            }
        }