Basic Login Server Packets.
Esempio n. 1
0
        static public void LoginPacket(ref NetworkStream ns, Client client)
        {
            string username, password;

            {
                byte[] byte_username = new byte[30];
                byte[] byte_password = new byte[30];

                ns.Read(byte_username, 0, 30);
                ns.Read(byte_password, 0, 30);
                ns.ReadByte(); // next-login-key;

                username = Packets.GetString(byte_username);
                password = Packets.GetString(byte_password);
            }
            if (Auth.CanLogin(username, password))
            {
                Console.WriteLine("Client connected: {0}", username);
                SendServerList(ref ns, client);
            }
            else
            {
                SendLoginDenied(ref ns, (byte)00);
            }
        }
Esempio n. 2
0
        void HandleClient()
        {
            NetworkStream ns = client_sock.GetStream();
            int           c  = -1;

            // Seed Start
            c = ns.ReadByte();
            if (c == 0xEF)
            {
                Packets.SeedPacket(ref ns, ref client_version);
            }
            else
            {
                byte[] seed = new byte[3];
                ns.Read(seed, 0, 3);
            }
            // Seed End

            while ((c = ns.ReadByte()) >= 0)
            {
                switch (c)
                {
                case 0x80:
                    Console.WriteLine("Login Packet!");
                    Packets.LoginPacket(ref ns, this);
                    break;

                case 0xA0:
                    Console.WriteLine("Server Select!");
                    Packets.ServerSelectPacket(ref ns, this);
                    break;

                default:
                    byte[] tmp = new byte[1024];
                    int    len = ns.Read(tmp, 0, 1024);
                    HexDump.DumpUnk((byte)c, tmp, len, SockUtils.GetIP(client_sock));
                    break;
                }
            }
            Console.WriteLine("Client Disconnected!");
            _disconnected = true;
        }