Example #1
0
        public static void Update(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO)
        {
            Entry.Session  = ReaderIO.Reader.ReadBytes(0x10).ToHex();
            Entry.Title    = ReaderIO.Reader.ReadBytes(0x4).ToHex();
            Entry.GamerTag = ReaderIO.Reader.ReadBytes(0x15).ToString();

            if (ClientSQL.Get(ref Entry, true))
            {
                if (Entry.Enabled)
                {
                    WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS);
                }
                else
                {
                    if (ClientSQL.Increment(ref Entry, true))
                    {
                        if (Entry.AutoIncrement)
                        {
                            ClientSQL.Increment(ref Entry);
                        }
                        WriterIO.Writer.Write(Entry.AutoIncrement ? (Entry.noto_DayStarted ? (uint)respCode.RESP_DAY_STARTED : (uint)respCode.RESP_SUCCESS) : (uint)respCode.RESP_REBOOT);
                    }
                    else
                    {
                        WriterIO.Writer.Write((uint)respCode.RESP_ERROR);
                    }
                } ClientSQL.Set(ref Entry);
            }
        }
Example #2
0
        public Client Ajouter(Client client)
        {
            var cli = new ClientSQL();

            cli.Ajouter(client);
            return(client);
        }
Example #3
0
        public static void Get(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO)
        {
            Entry.Session    = ReaderIO.Reader.ReadBytes(0x10).ToHex();
            Entry.ClientHash = ReaderIO.Reader.ReadBytes(0x10);

            if (ClientSQL.Get(ref Entry, true))
            {
                if (!Entry.Enabled)
                {
                    GlobalFunc.WriteError(ConsoleColor.DarkGray, "Client [{0}]", "{1} has expired.", Entry.IP, Entry.Name);
                    WriterIO.Writer.Write((uint)respCode.RESP_EXPIRED);
                }

                if (!GlobalVar.b_xexChecks)
                {
                    GlobalFunc.WriteError(ConsoleColor.Red, "[SERVER]", "XEX Checks are disabled!");
                    WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS);
                }

                if (Entry.Checks)
                {
                    if (BitsNBytes.ByteCompare(Entry.ClientHash, HMAC.SHA1(GlobalVar.by_xexBytes, Entry.Session.ToByte(), 0, 16)))
                    {
                        GlobalFunc.WriteError(ConsoleColor.Green, "Client [{0}]", "{1} passed checks.", Entry.IP, Entry.Name);
                        WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS);
                    }
                    else
                    {
                        GlobalFunc.WriteError(ConsoleColor.Yellow, "Client [{0}]", "Out of date client! Sending update.", Entry.IP);
                        WriterIO.Writer.Write((uint)respCode.RESP_UPDATE);
                        WriterIO.Writer.Write(GlobalVar.by_xexBytes.Length);
                        WriterIO.Writer.Write(GlobalVar.by_xexBytes);
                    }
                }
                else
                {
                    GlobalFunc.WriteError(ConsoleColor.DarkYellow, "[ADMIN]", "Admin has omitted checks on user.");
                    WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS);
                }
            }
            else
            {
                GlobalFunc.WriteError(ConsoleColor.Red, "[UNAUTHORIZED]", "Unknown client. IP: {0}", Entry.IP);
                WriterIO.Writer.Write((uint)respCode.RESP_ERROR);
            }
        }
Example #4
0
 public static bool Authorization(string UserName, string Password)
 {
     SetAuthConnection(UserName, Password);
     connection = new MySqlConnection(connectionstring.ToString());
     try
     {
         connection.Open();
         client = new ClientSQL(connection, locker);
         Logger.WriteLog("Open MySQL connection.", LogLevel.Usual);
         return(true);
     }
     catch (Exception e)
     {
         Logger.WriteLog("Can't authorize user to database. Message->" + e.Message, LogLevel.Warning);
         return(false);
     }
 }
Example #5
0
 private void ListenThread()
 {
     try {
         this.Listener.Start();
         while (true)
         {
             Thread.Sleep(100);
             ClientSQL.CronCheck();
             if (!GlobalVar.b_serverRunning)
             {
                 return;
             }
             if (this.Listener.Pending())
             {
                 new Thread(new ParameterizedThreadStart(HandleClient)).Start(Listener.AcceptTcpClient());
             }
         }
     } catch (Exception ex) { GlobalVar.b_serverRunning = false; Console.Clear(); GlobalFunc.WriteError(ConsoleColor.Red, "[ERROR]", "Error ListenThread! Reason: {0}", ex.Message); GlobalFunc.DelayedRestart(3); }
 }
 public PDFSaver(ClientSQL clientSQL)
 {
     this.clientSQL = clientSQL;
 }
Example #7
0
 public ExcelSaver(ClientSQL clientSQL)
 {
     this.clientSQL = clientSQL;
 }
Example #8
0
        public void ModifierClient(Client client)
        {
            var cli = new ClientSQL();

            cli.ModifierClient(client);
        }
Example #9
0
        public void SupprimerClient(int id)
        {
            var cli = new ClientSQL();

            cli.SupprimerClient(id);
        }
Example #10
0
        public List <Client> GetList()
        {
            var serviceClient = new ClientSQL();

            return(serviceClient.GetList());
        }
Example #11
0
        public void CreerClient(Client client)
        {
            var cli = new ClientSQL();

            cli.CreerClient(client);
        }
Example #12
0
        public Client GetClient(int id)
        {
            var service = new ClientSQL();

            return(service.GetList()[id]);
        }
Example #13
0
 public Client()
 {
     m_clientSQL = new ClientSQL();
 }
Example #14
0
 public WordSaver(ClientSQL clientSQL)
 {
     this.clientSQL = clientSQL;
 }
Example #15
0
        public static void Get(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO)
        {
            bool conType = Convert.ToBoolean(ReaderIO.Reader.ReadInt32());

            Entry.CPUKey = ReaderIO.Reader.ReadBytes(0x10).ToHex();

            if (ClientSQL.Get(ref Entry))
            {
                Entry.Session = BitsNBytes.RandomBytes(0x10).ToHex();
                if (Entry.Enabled)
                {
                    GlobalFunc.Write("Client [{0}] {1}'s {2} Authorized!", Entry.IP, Entry.Name, conType ? "Devkit" : "Jtag/RGH");
                    WriterIO.Writer.Write((uint)respCode.RESP_STEALTHED);
                    WriterIO.Writer.Write(Entry.Session.ToByte());
                }
                else
                {
                    if (ClientSQL.Increment(ref Entry, true))
                    {
                        if (Entry.AutoIncrement)
                        {
                            if (ClientSQL.Increment(ref Entry))
                            {
                                if (Entry.noto_AskDayStart && Entry.noto_DayStarted)
                                {
                                    // ask about starting the day
                                    if (/*Asking result*/ true == false)
                                    {
                                        WriterIO.Writer.Write((uint)respCode.RESP_EXPIRED);
                                    }
                                    WriterIO.Writer.Write((uint)respCode.RESP_DAY_STARTED);
                                }
                                else if (Entry.noto_DayStarted)
                                {
                                    if (Entry.Lifetime)
                                    {
                                        WriterIO.Writer.Write((uint)respCode.RESP_STEALTHED);                 // Responds without notification
                                    }
                                    else
                                    {
                                        WriterIO.Writer.Write((uint)respCode.RESP_DAY_STARTED);
                                    }
                                }
                                else if (!Entry.noto_DayStarted)
                                {
                                    WriterIO.Writer.Write((uint)respCode.RESP_STEALTHED); // Responds without notification
                                }
                                WriterIO.Writer.Write(Entry.Session.ToByte());
                            }
                            else
                            {
                                GlobalFunc.WriteError(ConsoleColor.DarkGray, "Client [{0}]", "{1}'s Time Expired!", Entry.IP, Entry.Name);
                                WriterIO.Writer.Write((uint)respCode.RESP_EXPIRED);
                            }
                        }
                        else
                        {
                            GlobalFunc.WriteError(ConsoleColor.DarkGray, "Client [{0}]", "{1} opted out of incrementing a day.", Entry.IP, Entry.Name);
                            WriterIO.Writer.Write((uint)respCode.RESP_REBOOT);
                        }
                    }
                }
            }
            else
            {
                // who duh fuk u be
            }
        }