示例#1
0
        public void TestUncompressionFirstUse()
        {
            var compress = new CompressionInputContext(new byte[]
            {
                7,     // Length of 'example'
                101,
                120,
                97,
                109,
                112,
                108,
                101,
                3,     // Length of com
                99,
                111,
                109,
                0     // Length of root
            });
            Tuple <Domain, int> domain_info = compress.ReadDomainAt(0);

            var expected_domain = new Domain("example.com");
            var expected_offset = 13;

            Assert.That(domain_info.Item1, Is.EqualTo(expected_domain));
            Assert.That(domain_info.Item2, Is.EqualTo(expected_offset));
        }
示例#2
0
        public void TestUncompressionPointer()
        {
            var compress = new CompressionInputContext(new byte[]
            {
                7,     // Length of 'example'
                101,
                120,
                97,
                109,
                112,
                108,
                101,
                3,     // Length of com
                99,
                111,
                109,
                0,     // Length of root
                3,     // Length of dns
                100,
                110,
                115,
                // Pointer to start of context
                192,
                0
            });
            Tuple <Domain, int> domain_info = compress.ReadDomainAt(13);

            var expected_domain = new Domain("dns.example.com");
            var expected_offset = 19;

            Assert.That(domain_info.Item1, Is.EqualTo(expected_domain));
            Assert.That(domain_info.Item2, Is.EqualTo(expected_offset));
        }
示例#3
0
        /**
         * Reads a domain name from the input stream.
         */
        public Domain ReadDomain()
        {
            Tuple <Domain, int> domain_info = compress.ReadDomainAt((int)stream.Position);

            stream.Seek(domain_info.Item2, SeekOrigin.Begin);
            return(domain_info.Item1);
        }