private void HandleDesktopLogin(byte[] message)
        {
            short  length = BitConverter.ToInt16(message, 0);
            string msg    = Encoding.UTF8.GetString(message, 2, length);

            //msg = this.DecryptDesktop(msg, "FORGEREMOTETIVITY");
            byte[] bs = new byte[1];
            //Server.s.Log(msg);
            if (msg.StartsWith(Protocal.ToString())) //TODO: make a better checker
            {
                msg = msg.Replace(string.Format("{0}: ", Protocal), string.Empty);
            }
            else
            {
                bs[0] = 3;
                SendData(0x40, bs);
                Server.s.Log("[Remote] A remote tried to connect with a different version.");
                return;
            }
            if (RemoteServer.tries >= 3)
            {
                bs[0] = 4;
                SendData(0x40, bs);
                Server.s.Log("[Remote] A remote tried to connect with exceeding incorrect credentials");
                return;
            }
            if (RemoteServer.tries == 6)
            {
                bs[0] = 5;
                SendData(0x40, bs);
                Server.s.Log("[Remote] Remote was locked from the console, type \"/remote tryreset\" to reset the try count");
                return;
            }

            if (HandleLogin(msg))
            {
                bs[0] = 1;
                if (OnRemoteLogin != null)
                {
                    OnRemoteLogin(this);
                }
                SendData(0x40, bs);
                Server.s.Log("[Remote] Remote Verified, passing controls to it!");
                LoggedIn = true;
                if (Remotes != null)
                {
                    Remotes.Add(this);
                }
                RegEvents();
                //StartUpDesktop();
                return;
            }
            bs[0] = 2;
            SendData(0x40, bs);
            Server.s.Log("[Remote] A Remote with incorrect information attempted to join.");
            RemoteServer.tries++;
            return;
        }
示例#2
0
        private void HandleMobileLogin(byte[] message)
        {
            short  length = util.EndianBitConverter.Big.ToInt16(message, 0);
            string msg    = Encoding.UTF8.GetString(message, 2, length);

            msg = DecryptMobile(msg, "FORGEREMOTETIVITY");
            byte[] bs = new byte[1];
            //Server.s.Log(msg);
            if (msg.StartsWith(Protocal.ToString())) //TODO: make a better checker
            {
                msg = msg.Replace(string.Format("{0}: ", Protocal), "");
            }
            else
            {
                bs[0] = 0x3;
                SendData(0xb, bs);
                Server.s.Log("[Remote] A remote tried to connect with a different version.");
            }
            if (RemoteServer.tries >= 0x3)
            {
                bs[0] = 0x4;
                SendData(0xb, bs);
                Server.s.Log("[Remote] A remote tried to connect with exceeding incorrect credentials");
            }
            if (RemoteServer.tries == 0x6)
            {
                bs[0] = 0x5;
                SendData(0xb, bs);
                Server.s.Log("[Remote] Remote was locked from the console, type \"/remote tryreset\" to reset the try count");
            }

            if (HandleLogin(msg))
            {
                bs[0] = 1;
                if (OnRemoteLogin != null)
                {
                    OnRemoteLogin(this);
                }
                SendData(11, bs);
                GenerateKeyMobile(_keyMobile);
                Server.s.Log("[Remote] Remote Verified, passing controls to it!");
                LoggedIn = true;
                Remotes.Add(this);
                regMobileEvents();
            }
            else
            {
                bs[0] = 0x2;
                SendData(11, bs);
                Server.s.Log("[Remote] A Remote with incorrect information attempted to join.");
                RemoteServer.tries++;
            }
        }
示例#3
0
        private void ProcessReceiveBuffer(byte[] buffer, Protocal type)
        {
            timeOutWatch.Reset();
            timeOutWatch.Start();

            if (buffer.Length > 0)
            {
                byte command = buffer[0];
                buffer = BufferUtils.RemoveFront(BufferUtils.Remove.CMD, buffer);
                Data data = new Data(type, command, buffer);
                _server.Process(this, data);
            }
            else
            {
                Logger.Log("{1}: Received empty buffer!", type.ToString());
            }
        }