Ejemplo n.º 1
0
        public static void HandleServer(World.Client client, byte[] buffer)
        {
            if (buffer == null || client == null)
                return;
            if (PacketSniffing.Sniffing)
                PacketSniffing.Sniff(buffer, true);
            ushort length = BitConverter.ToUInt16(buffer, 0);
            ushort id = BitConverter.ToUInt16(buffer, 2);

            bool send = true;

            switch (id)
            {
                #region [1004] Chat
                case 1004: Handlers.Chat(client, new Message(buffer), out send); break;
                #endregion
                #region [1052] Login
                case 1052: client.Identity = BitConverter.ToUInt32(buffer, 4); break;
                #endregion
            }
            if (Program.ConsoleLogging && send)//hides any command to the proxy
            {
                int PacketID = id;
                string PacketName = "";
                if (Enum.IsDefined(typeof(Connections.Packets.Packets.PacketsEnum), PacketID))
                {
                    PacketName = " (" + PacketSniffing.AddSpacesToSentence(Enum.GetName(typeof(Connections.Packets.Packets.PacketsEnum), PacketID)) + ")";
                }
                Console.WriteLine("New packet passed from client -> server | Packet ID: " + id + PacketName + " | Size: " + length);
                Console.ResetColor();
                Console.WriteLine(PacketOutput.Dump(buffer));
                Console.ForegroundColor = ConsoleColor.White;
            }
            if (send)
                client.SendToServer(buffer);
        }