Exemplo n.º 1
0
        public void RequestPatches(AutoUpdateRequestType mode, PatchServer server)
        {
            if (!Kernel.HasAgreedPrivacy)
            {
                NoDownload(UpdateReturnMessage.PrivacyNotAccepted, false);
                return;
            }

            MsgRequestInfo msg = new MsgRequestInfo
            {
                Mode = mode
            };

            switch (mode)
            {
            case AutoUpdateRequestType.CheckForLauncherUpdates:
                msg.CurrentVersion = m_usClientVersion;
                break;

            case AutoUpdateRequestType.CheckForGameUpdates:
                msg.CurrentVersion = m_usCurrentVersion;
                break;
            }

            server.Send(msg);
        }
        public void ProcessRequestInfo(PatchServer server, byte[] buffer)
        {
            MsgRequestInfo msg = new MsgRequestInfo(buffer);

            switch (msg.Mode)
            {
            case AutoUpdateRequestType.LauncherUpdatesOk:
                Kernel.Stage = AutoPatchStage.WaitingForGamePatchs;
                Program.FrmMain.RequestPatches(AutoUpdateRequestType.CheckForGameUpdates, server);
                break;

            case AutoUpdateRequestType.GameUpdatesOk:
                Program.FrmMain.NoDownload(UpdateReturnMessage.Success);
                break;

            case AutoUpdateRequestType.CheckForGameUpdates:
            case AutoUpdateRequestType.CheckForLauncherUpdates:
                if (msg.CurrentVersion == 0)
                {
                    Program.FrmMain.NoDownload(UpdateReturnMessage.DoubleClient, false);
                }
                else
                {
                    Program.FrmMain.NoDownload(UpdateReturnMessage.LoginNotAllowed, false);
                }
                break;
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            MsgRequestInfo msg = new MsgRequestInfo();

            msg.Create(AutoUpdateRequestType.CheckForGameUpdates);
            Console.WriteLine(PacketDump.Hex(msg));

            MsgRequestInfo decode = new MsgRequestInfo(msg);

            Console.WriteLine(PacketDump.Hex(msg));

            StringPacker packer = new StringPacker("Testando", "Aurelio", "Felipe", "Teste", "StringPacker", "FTW! Masters");

            Console.WriteLine(PacketDump.Hex(packer.ToArray()));

            packer = new StringPacker(packer.ToArray());
            foreach (var str in packer.GetStrings())
            {
                Console.WriteLine(str);
            }

            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public void PrepareToDownload(UpdateDownloadType type, List <string> strs, PatchServer server)
        {
            HideDownloadBar();
            if (strs.Count < 2)
            {
                if (type == UpdateDownloadType.UpdaterPatch)
                {
                    MsgRequestInfo mri = new MsgRequestInfo();
                    mri.CurrentVersion = m_usCurrentVersion;
                    server.Send(mri);

                    Kernel.Stage = AutoPatchStage.WaitingForGamePatchs;
                    Edit(lblCenterStatus, LabelAsyncOperation.Text,
                         LanguageManager.GetString("StrLookingForGameUpdates"));
                }
                else
                {
                    NoDownload(UpdateReturnMessage.Success);
                }

                return;
            }

            m_actuallyDownloading = type;
            Edit(lblCenterStatus, LabelAsyncOperation.Text, LanguageManager.GetString("StrCalculatingDownloadSize"));

            string domain = strs[0];

            if (!domain.EndsWith("/"))
            {
                domain += "/";
            }

            m_nTotalDownloadSize  = 0;
            m_nCurrentDownloading = 0;
            m_nTotalDownloads     = 0;

            Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                 LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                           ParseFileSize(m_nTotalDownloadSize)));
            Edit(lblDownloadStatus, LabelAsyncOperation.Visible, true);

            for (int i = 1; i < strs.Count; i++)
            {
                if (!strs[i].EndsWith(".exe"))
                {
                    strs[i] += ".exe";
                }

                if (!RemoteFileExists($"{domain}{strs[i]}"))
                {
                    continue;
                }

                m_nTotalDownloadSize += FetchFileSize($"{domain}{strs[i]}");
                m_nTotalDownloads++;
                m_queueNextDownloads.Enqueue($"{domain}{strs[i]}");
                Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                     LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                               ParseFileSize(m_nTotalDownloadSize)));
            }

            Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                 LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                           ParseFileSize(m_nTotalDownloadSize)));
            Edit(pbDownload, ProgressBarAsyncOperation.Value, 0);
            Edit(pbDownload, ProgressBarAsyncOperation.Max, m_nTotalDownloadSize);
            ShowDownloadBar();
            StartDownloading();
        }
        public void ProcessRequestInfo(User user, byte[] buffer)
        {
            MsgRequestInfo msg = new MsgRequestInfo(buffer);

            if (user.IsBanned || !Kernel.AllowedUsers.ContainsKey(user.MacAddress))
            {
                Program.WriteLog($"User [{user.IpAddress}::{user.MacAddress}] is not allowed to download patches.", LogType.WARNING);
                msg.CurrentVersion = ushort.MaxValue;
                user.Send(msg);
                return;
            }

            Program.WriteLog($"User [{user.IpAddress}::{user.MacAddress}] has requested updates with current version: {msg.CurrentVersion}.");
            List <PatchStructure> updates = UpdatesManager.GetDownloadList(msg.CurrentVersion);

            switch (msg.Mode)
            {
            case AutoUpdateRequestType.CheckForLauncherUpdates:
                if (updates.Count > 0)
                {
                    MsgDownloadInfo pMsg = new MsgDownloadInfo
                    {
                        Mode          = UpdateDownloadType.UpdaterPatch,
                        LatestVersion = (ushort)Kernel.LatestUpdaterPatch
                    };
                    pMsg.Append(Kernel.DownloadUrl);
                    foreach (var patch in updates)
                    {
                        pMsg.Append(patch.FileName);
                    }

                    user.Send(pMsg);
                }
                else
                {
                    msg.Mode = AutoUpdateRequestType.LauncherUpdatesOk;
                    user.Send(msg);
                }

                break;

            case AutoUpdateRequestType.CheckForGameUpdates:
                if (updates.Count > 0)
                {
                    MsgDownloadInfo pMsg = new MsgDownloadInfo
                    {
                        Mode          = UpdateDownloadType.GameClientPatch,
                        LatestVersion = (ushort)Kernel.LatestGamePatch
                    };
                    pMsg.Append(Kernel.DownloadUrl);
                    foreach (var patch in updates)
                    {
                        pMsg.Append(patch.FileName);
                    }

                    user.Send(pMsg);
                }
                else
                {
                    msg.Mode = AutoUpdateRequestType.GameUpdatesOk;
                    user.Send(msg);
                }

                break;
            }
        }