Exemplo n.º 1
0
        public override void Parse(STUNMessage msg, STUNBinaryReader binary, int length)
        {
            binary.BaseStream.Position++;
            var       ipFamily = binary.ReadByte();
            var       port     = binary.ReadUInt16();
            IPAddress address;

            if (ipFamily == 1)
            {
                address = new IPAddress(binary.ReadBytes(4));
            }
            else if (ipFamily == 2)
            {
                address = new IPAddress(binary.ReadBytes(16));
            }
            else
            {
                throw new Exception("Unsupported IP Family " + ipFamily.ToString());
            }

            EndPoint = new IPEndPoint(address, port);
        }