Exemplo n.º 1
0
        public static byte[] SendKeepPacket(byte type, bool fake, int count, byte[] tail, byte[] IP)
        {
            Packet packet = new Packet(new byte[] {
                0x07, (byte)count,
                0x28, 0x00,
                0x0b, type,
                (byte)(fake ? 0x0f : 0xdc), (byte)(fake ? 0x27 : 0x02),
                PacketUtils.RandomByte(), PacketUtils.RandomByte(),
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            });

            packet += tail;
            packet += new byte[] {
                0x00, 0x00, 0x00, 0x00
            };
            if (type == 0x03)
            {
                packet += PacketUtils.CRC(packet + IP);
                packet += IP;
                packet += new byte[] {
                    0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00
                };
            }
            else
            {
                packet += new byte[]
                {
                    0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00
                };
            }
            return(NetworkUtils.SendUDPDatagram(packet));
        }