예제 #1
0
        internal static void LoginGame(AionConnection client, byte serverId)
        {
            GameInfo value = null;

            if (gameservers.TryGetValue(serverId, out value))
            {
                if (!value.IsOnline())
                {
                    client.SendPacket(new SM_PLAY_FAIL(AionAuthResponse.SERVER_DOWN));
                    return;
                }
                if (value.IsFull())
                {
                    client.SendPacket(new SM_PLAY_FAIL(AionAuthResponse.SERVER_FULL));
                    return;
                }
                client.JoinGS = true;
                client.SendPacket(new SM_PLAY_OK(client.SessionKey, serverId));
                log.InfoFormat("登陆账号: {0} 进入 #{1}号游戏服务器!", (object)client.Account.Name, (object)serverId);
            }
            else
            {
                log.WarnFormat("来自: {0} 的用户尝试进入不存在的游戏服务器({1})!", (object)client.Account.Name, (object)serverId);
            }
        }
예제 #2
0
 private void AddNewClient(AionConnection aion)
 {
     aion.OnDisconnected += OnDisconnected;
     aion.StartReceivePacket();
     clients.Add(checked ((int)aion.ClientID), aion);
     log.InfoFormat("收到来自 {0} 的客户端连接!", (object)aion.IP);
 }
예제 #3
0
        internal static void CheckAuth(SessionKey key, GameConnection client)
        {
            AionConnection value = null;

            if (Conversions.ToBoolean(accountOnLS.TryGetValue(key.AccountId, out value) && Conversions.ToBoolean(value.SessionKey.CheckSessionKey(key))))
            {
                accountOnLS.Remove(key.AccountId);
                GameInfo gameInfo = GameService.GameServerIndoForId(client.GameServerId);
                Account  account  = value.Account;
                gameInfo.AddAccount(account);
                account.LastServer = checked ((byte)gameInfo.ServerId);
                LunaInfo lunaInfo = DAOManager.LunaDAO.LoadLuna(key.AccountId);
                if (Information.IsNothing(lunaInfo))
                {
                    DateTime time = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 9, 0, 0);
                    lunaInfo = new LunaInfo(key.AccountId, 0L, 0, 0, 0, time);
                    DAOManager.LunaDAO.Store(lunaInfo);
                }
                account.LunaInfo = lunaInfo;
                client.SendPacket(new SM_GS_ACCOUNT_AUTH_RESPONSE(key.AccountId, ok: true, account));
                DAOManager.AccountDAO.UpdateLastIpAndServer(account);
                if (ExpirationConfig.EXPIRATION_ENABLE)
                {
                    ExpirationService.GetInstance().Add(account);
                }
            }
            else
            {
                client.SendPacket(new SM_GS_ACCOUNT_AUTH_RESPONSE(key.AccountId, ok: false, null));
            }
        }
예제 #4
0
        protected override void writeImpl(AionConnection con)
        {
            int id  = con.Account.Id;
            int num = 0;
            Dictionary <int, int> dictionary = GameService.CharacterCountsFor(id);

            writeC(dictionary.Count);
            writeC(con.Account.LastServer);
            foreach (GameInfo allGameServer in GameService.AllGameServers)
            {
                if (allGameServer.ServerId > num)
                {
                    num = allGameServer.ServerId;
                }
                writeC(allGameServer.ServerId);
                if (allGameServer.IsOnline())
                {
                    writeB(allGameServer.SlbAddress(con.Account));
                }
                else
                {
                    writeB(4);
                }
                writeD(allGameServer.Port);
                writeC(0);
                writeC(1);
                writeH(allGameServer.CurrentPlayers());
                writeH(allGameServer.MaxPlayers);
                writeBC(allGameServer.IsOnline());
                writeD(1);
                writeC(0);
            }
            checked
            {
                writeH(num + 1);
                writeC(1);
                int num2 = num;
                for (int i = 1; i <= num2; i++)
                {
                    if (dictionary.ContainsKey(i))
                    {
                        writeC(dictionary[i]);
                    }
                    else
                    {
                        writeC(0);
                    }
                }
                if (Operators.CompareString(LoginConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0)
                {
                    writeC(0);
                    writeH(0);
                    writeD(1097983527);
                    writeD(0);
                }
            }
        }
예제 #5
0
        protected override void writeImpl(AionConnection con)
        {
            writeD(_key.PlayerOk1);
            writeD(_key.PlayerOk2);

            //if (Operators.CompareString(LoginConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0)
            //{
            writeC(_serverId);
            writeB(14);
            //}
        }
예제 #6
0
 protected override void writeImpl(AionConnection con)
 {
     writeD(checked ((int)con.ClientID));
     if (Operators.CompareString(LoginConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0)
     {
         writeB(35);
     }
     else
     {
         writeB(16);
     }
 }
예제 #7
0
 protected override void writeImpl(AionConnection con)
 {
     writeD(checked ((int)con.ClientID));
     writeD(50721);
     writeB(_rsaKey);
     writeB(16);
     writeB(_blowfishKey);
     writeD(197635);
     if (Operators.CompareString(LoginConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0)
     {
         writeB(19);
     }
     else
     {
         writeD(2097152);
     }
 }
예제 #8
0
 protected override void writeImpl(AionConnection con)
 {
     writeD(_key.AccountId);
     writeD(_key.LoginOk);
     writeD(0);
     writeD(0);
     if (Operators.CompareString(LoginConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0)
     {
         writeD(2000);
         writeD(82570696);
         writeB(47);
     }
     else
     {
         writeD(1002);
         writeB(28);
     }
 }
예제 #9
0
 public void write(AionConnection con)
 {
     checked
     {
         using MemoryStream memoryStream = new MemoryStream();
         base.Wbuf = new BinaryWriter(memoryStream);
         base.Wbuf.Write((short)0);
         base.Wbuf.Write((byte)base.OpCode);
         writeImpl(con);
         int length = (int)(memoryStream.Length - 4);
         int num    = con.CheckSum(length);
         memoryStream.Position = 0L;
         base.Wbuf.Write((short)(num + 2));
         base.PacketData = memoryStream.ToArray();
         base.PacketData = (byte[])Utils.CopyArray(base.PacketData, new byte[num + 1 + 1]);
         byte[] packetData = base.PacketData;
         con.Encrypt(ref packetData, 2, num);
         base.PacketData = packetData;
     }
 }
예제 #10
0
        private void OnDisconnected(object sender, EventArgs e)
        {
            AionConnection aionConnection = (AionConnection)sender;

            clients.Remove(checked ((int)aionConnection.ClientID));
        }
예제 #11
0
        internal static AionAuthResponse Login(string userName, string password, AionConnection client)
        {
            Account account = LoadAccount(userName);

            if (Information.IsNothing(account) & LoginConfig.ACCOUNT_AUTO_CREATION)
            {
                account = CreateAccount(userName, password);
            }
            if (Information.IsNothing(account))
            {
                return(AionAuthResponse.INVALID_PASSWORD);
            }
            if (!account.Password.Equals(RuntimeHelpers.GetObjectValue(EncodePassword(password))))
            {
                if (LoginConfig.PASSWORD_CHECK_ENABLE)
                {
                    BruteForceProtector.AddFailedLogin(userName, client.IP);
                }
                return(AionAuthResponse.INVALID_PASSWORD);
            }
            if (account.Activated != 1)
            {
                return(AionAuthResponse.BAN_ACCOUNT);
            }
            string text = client.IP.Split(':')[0];

            if (BannedIpController.IsBannedIp(text))
            {
                return(AionAuthResponse.BAN_IP);
            }
            if (!GameService.HahServerOnline())
            {
                return(AionAuthResponse.NOT_SERVER_ONLINE);
            }
            object @lock = _lock;

            ObjectFlowControl.CheckForSyncLockOnValueType(@lock);
            bool lockTaken = false;

            try
            {
                Monitor.Enter(@lock, ref lockTaken);
                if (GameService.ContainsAccount(account.Id))
                {
                    GameService.KickAccountFromGameServer(account.Id);
                    return(AionAuthResponse.ALREADY_LOGGED_IN);
                }
                if (accountOnLS.ContainsKey(account.Id))
                {
                    accountOnLS[account.Id].Disconnect();
                    accountOnLS.Remove(account.Id);
                    return(AionAuthResponse.ALREADY_LOGGED_IN);
                }
                client.Account = account;
                accountOnLS.Add(account.Id, client);
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(@lock);
                }
            }
            account.LastIp = text;
            account.AccountTime.LastLoginTime = DateAndTime.Now;
            AccountTimeController.UpDataLoginTime(account);
            return(AionAuthResponse.AUTHED);
        }
예제 #12
0
        internal static void AuthReconnectingAccount(int accountId, int loginOk, int rekey, AionConnection client)
        {
            ReConnectionAccount value = null;

            if (reconnectingAccounts.TryGetValue(accountId, out value) && value.ReKey == rekey)
            {
                reconnectingAccounts.Remove(accountId);
                client.Account = value.Account;
                accountOnLS.Add(value.Account.Id, client);
                client.State      = State.AUTHED_LOGIN;
                client.SessionKey = new SessionKey(client.Account);
                client.SendPacket(new SM_UPDATE_SESSION(client.SessionKey));
            }
            else
            {
                client.Disconnect();
            }
        }
예제 #13
0
 protected abstract void writeImpl(AionConnection con);