Пример #1
0
        /// <summary>
        /// Analyze server packets.
        /// </summary>
        /// <param name="packet">Server packet</param>
        /// <returns>True if the packet will be ignored by the client</returns>
        private bool Remote_PacketHandler(Packet packet)
        {
            switch (packet.Opcode)
            {
            case Opcode.GLOBAL_IDENTIFICATION:
                if (ClientlessMode)
                {
                    string service = packet.ReadAscii();
                    if (service == "GatewayServer")
                    {
                        Packet p = new Packet(Opcode.CLIENT_PATCH_REQUEST, true);
                        p.WriteByte(DataManager.Locale);
                        p.WriteAscii(DataManager.SR_Client);
                        p.WriteUInt(DataManager.Version);
                        InjectToServer(p);
                    }
                }
                break;

            case Opcode.SERVER_PATCH_RESPONSE:
                if (ClientlessMode)
                {
                    switch (packet.ReadByte())
                    {
                    case 1:
                        Packet p = new Packet(Opcode.CLIENT_SHARD_LIST_REQUEST, true);
                        this.InjectToServer(p);
                        break;

                    case 2:
                        byte errorCode = packet.ReadByte();
                        if (errorCode == 2)
                        {
                            string DownloadServerIP         = packet.ReadAscii();
                            ushort DownloadServerPort       = packet.ReadUShort();
                            uint   DownloadServerCurVersion = packet.ReadUInt();
                            Window.Get.Log("Version outdate. Please, verify that client and database (v" + DataManager.Version + ") are up to date (v" + DownloadServerCurVersion + ")");
                        }
                        else
                        {
                            Window.Get.Log("Patch error: [" + errorCode + "]");
                        }
                        Bot.Get.Proxy.Stop();
                        break;
                    }
                }
                break;

            case Opcode.SERVER_SHARD_LIST_RESPONSE:
                PacketParser.ShardListResponse(packet);
                break;

            case Opcode.SERVER_CAPTCHA_DATA:
                PacketParser.CaptchaData(packet);
                break;

            case Opcode.SERVER_CAPTCHA_SOLVED_RESPONSE:
                // success
                if (packet.ReadBool())
                {
                    Window.Get.Log("Captcha entered successfully!");
                }
                else
                {
                    uint maxAttempts = packet.ReadUInt();
                    uint attempts    = packet.ReadUInt();
                    Window.Get.Log("Captcha entry has failed (" + attempts + " / " + maxAttempts + " attempts)");
                }
                break;
            }
            return(false);
        }