Пример #1
0
        public void OnUserRequestUpdateDateTime(Client client)
        {
            DateTime dateTime = default(DateTime);

            switch (OPT.GetInt("send.type"))
            {
            case 0:
                dateTime = Directory.GetLastWriteTimeUtc(indexPath);
                break;

            case 1:
                break;

            case 2:
                break;

            case 3:
                dateTime = Directory.GetLastWriteTimeUtc(updatesDir);
                break;
            }

            if (dateTime != default(DateTime))
            {
                ClientPackets.Instance.SC_SendUpdateTime(client, dateTime.ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                Console.WriteLine("Failed to get proper update time for Client [{0}]", client.Id);
            }
        }
Пример #2
0
 internal void OnUserRequestUpdatesEnabled(Client client)
 {
     if (OPT.SettingExists("disable.updating"))
     {
         ClientPackets.Instance.SC_SendUpdatesDisabled(client, OPT.GetInt("disable.updating"));
     }
 }
Пример #3
0
        public void OnUserRequestUpdateDateTime(Client client)
        {
            DateTime dateTime = default(DateTime);

            switch (OPT.GetInt("send.type"))
            {
            case 0:
                dateTime = Directory.GetLastWriteTimeUtc(indexPath);
                break;

            case 1:
                break;

            case 2:
                break;

            case 3:
                dateTime = Directory.GetLastWriteTimeUtc(IndexManager.UpdatesDirectory);
                break;
            }

            if (dateTime != default(DateTime))
            {
                ClientPackets.Instance.SC_SendUpdateTime(client, dateTime.ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                Output.Write(new Message()
                {
                    Text = string.Format("Failed to get proper update time for Client [{0}]", client.Id), AddBreak = true
                });
            }
        }
Пример #4
0
        internal void OnUserRequestArguments(Client client)
        {
            string arguments = string.Format("/auth_ip:{0} /auth_port:{1} /locale:? country:? /use_nprotect:0 /cash /commercial_shop /allow_double_exec:{2}", OPT.GetString("auth.io.ip"), OPT.GetString("auth.io.port"), OPT.GetString("double.execute"));

            if (OPT.GetBool("imbc.login"))
            {
                arguments += "/imbclogin /account:? /password:?";
            }

            ClientPackets.Instance.SC_SendArguments(client, arguments, OPT.GetInt("sframe.bypass"));
        }
Пример #5
0
        public void LoadUpdateList()
        {
            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] optBlocks = line.Split('|');
                        if (optBlocks.Length == 4)
                        {
                            UpdateIndex.Add(new IndexEntry {
                                FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3]))
                            });
                        }
                    }
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in Directory.GetFiles(updatesDir))
                {
                    string fileName = Path.GetFileName(filePath);

                    UpdateIndex.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }
        }
Пример #6
0
        internal void OnRequestResourceUpdateIndex(Client client)
        {
            if (Program.Wait)
            {
                ClientPackets.Instance.SC_SendWait(client, ClientPackets.Instance.currentPacketId, OPT.GetInt("wait.period"));
            }
            else
            {
                List <IndexEntry> filteredIndex = IndexManager.Filter(FilterType.Resource);

                foreach (IndexEntry indexEntry in filteredIndex)
                {
                    ClientPackets.Instance.SC_SendResourceEntry(client, indexEntry.FileName, indexEntry.SHA512, indexEntry.Delete);
                }

                ClientPackets.Instance.SC_SendResourceIndexEOF(client);
            }
        }
Пример #7
0
        public void OnRequestDataUpdateIndex(Client client)
        {
            if (Program.Wait)
            {
                ClientPackets.Instance.SC_SendWait(client, ClientPackets.Instance.currentPacketId, OPT.GetInt("wait.period"));
            }
            else
            {
                List <IndexEntry> filteredIndex = IndexManager.Filter(FilterType.Data);

                foreach (IndexEntry indexEntry in filteredIndex)
                {
                    ClientPackets.Instance.SC_SendDataEntry(client, indexEntry.FileName, indexEntry.SHA512);
                }

                ClientPackets.Instance.SC_SendDataIndexEOF(client);
            }
        }
Пример #8
0
 internal void OnAuthenticationTypeRequest(Client client)
 {
     ClientPackets.Instance.SC_SendAuthenticationType(client, OPT.GetInt("imbc.login"));
 }
Пример #9
0
        public static void Build(bool rebuild)
        {
            if (rebuild && OPT.GetBool("debug"))
            {
                Console.Write("Rebuilding the Update Index...");
            }
            else
            {
                Console.Write("Building the Update Index...");
            }

            Program.Wait = true;

            if (Index.Count > 0)
            {
                Index.Clear();
            }

            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    //string line;
                    //while ((line = sr.ReadLine()) != null)
                    //{
                    //    string[] optBlocks = line.Split('|');
                    //    if (optBlocks.Length == 4)
                    //    {
                    //        Index.Add(new IndexEntry { FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3])) });
                    //    }
                    //}
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in System.IO.Directory.GetFiles(UpdatesDirectory))
                {
                    string fileName = Path.GetFileName(filePath);

                    Index.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }

            if (rebuild && OPT.GetBool("debug"))
            {
                Console.WriteLine("[OK]\n\t{0} files indexed", Count);
            }
            else
            {
                Console.WriteLine("[OK]\n\t{0} files indexed", Count);
            }

            Program.Wait = false;
        }
Пример #10
0
        public static void Build(bool rebuild)
        {
            Output.WriteAndLock(new Message()
            {
                Text = string.Format("{0} the Update Index...", (rebuild && OPT.GetBool("debug")) ? "Rebuilding" : "Building")
            });

            if (rebuild)
            {
                Program.Wait = true;
            }

            if (Index.Count > 0)
            {
                Index.Clear();
            }

            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    //string line;
                    //while ((line = sr.ReadLine()) != null)
                    //{
                    //    string[] optBlocks = line.Split('|');
                    //    if (optBlocks.Length == 4)
                    //    {
                    //        Index.Add(new IndexEntry { FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3])) });
                    //    }
                    //}
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in System.IO.Directory.GetFiles(UpdatesDirectory))
                {
                    string fileName = Path.GetFileName(filePath);

                    Index.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }

            if (OPT.GetBool("debug"))
            {
                Output.WriteAndUnlock(new Message()
                {
                    Text = string.Format("[OK]\n\t- {0} files indexed", Count), AddBreak = true
                });
            }

            if (rebuild)
            {
                Program.Wait = false;
            }

            GUI.Instance.Invoke(new System.Windows.Forms.MethodInvoker(delegate {
                GUI.Instance.updatesViewBtn.Enabled = true;
                GUI.Instance.updatesView.Enabled    = true;
            }));
        }