Пример #1
0
        /// <summary>
        /// Tests equality between this TXT record and the other <paramref name="record"/>.
        /// </summary>
        /// <param name="record">The other record.</param>
        /// <returns><c>true</c> if the RRs are equal, <c>false</c> otherwise.</returns>
        public override bool Equals(DnsResourceRecord record)
        {
            if (!base.Equals(record))
            {
                return(false);
            }

            TextRecord textRecord = record as TextRecord;

            if (textRecord == null)
            {
                return(false);
            }

            if (this.HasStrings != textRecord.HasStrings || m_strings.Count != textRecord.Strings.Count)
            {
                return(false);
            }

            for (int i = 0, count = m_strings.Count; i < count; ++i)
            {
                if (!string.Equals(m_strings[i], textRecord.Strings[i], StringComparison.Ordinal))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Factory for DnsResourceRecord objects
        /// </summary>
        /// <param name="recordType"></param>
        /// <returns></returns>
        public static DnsResourceRecord CreateRecordObject(DnsStandard.RecordType recordType)
        {
            DnsResourceRecord record;

            switch (recordType)
            {
            default:
                record = new RawRecord();
                break;

            case DnsStandard.RecordType.ANAME:
                record = new AddressRecord();
                break;

            case DnsStandard.RecordType.NS:
                record = new NSRecord();
                break;

            case DnsStandard.RecordType.CNAME:
                record = new CNameRecord();
                break;

            case DnsStandard.RecordType.SOA:
                record = new SOARecord();
                break;

            case DnsStandard.RecordType.TXT:
                record = new TextRecord();
                break;

            case DnsStandard.RecordType.MX:
                record = new MXRecord();
                break;

            case DnsStandard.RecordType.PTR:
                record = new PtrRecord();
                break;

            case DnsStandard.RecordType.CERT:
                record = new CertRecord();
                break;

            case DnsStandard.RecordType.SRV:
                record = new SRVRecord();
                break;
            }

            return(record);
        }
Пример #3
0
        /// <summary>
        /// Prints a TXT RR
        /// </summary>
        /// <param name="body">The RR to print</param>
        public void Print(TextRecord body)
        {
            if (body == null)
            {
                m_writer.WriteLine("Null TXT Record Body");
                return;
            }

            if (!body.HasStrings)
            {
                m_writer.WriteLine("Empty TXT Record Body");
                return;
            }

            foreach (string sz in body.Strings)
            {
                if (sz == null)
                {
                    m_writer.WriteLine("Null string");
                }

                m_writer.WriteLine(sz);
            }
        }
Пример #4
0
        /// <summary>
        /// Factory for DnsResourceRecord objects
        /// </summary>
        /// <param name="recordType"></param>
        /// <returns></returns>
        public static DnsResourceRecord CreateRecordObject(DnsStandard.RecordType recordType)
        {
            DnsResourceRecord record;
            switch (recordType)
            {
                default:
                    record = new RawRecord();
                    break;

                case DnsStandard.RecordType.ANAME:
                    record = new AddressRecord();
                    break;

                case DnsStandard.RecordType.NS:
                    record = new NSRecord();
                    break;

                case DnsStandard.RecordType.CNAME:
                    record = new CNameRecord();
                    break;

                case DnsStandard.RecordType.SOA:
                    record = new SOARecord();
                    break;

                case DnsStandard.RecordType.TXT:
                    record = new TextRecord();
                    break;

                case DnsStandard.RecordType.MX:
                    record = new MXRecord();
                    break;
                
                case DnsStandard.RecordType.PTR:
                    record = new PtrRecord();
                    break;
                    
                case DnsStandard.RecordType.CERT:
                    record = new CertRecord();
                    break;
                
                case DnsStandard.RecordType.SRV:
                    record = new SRVRecord();
                    break;
            }
            
            return record;
        }
Пример #5
0
 public static void AddTestRecords(DnsRecordTable store)
 {
     // Addresses
     store.Add(new AddressRecord("foo.com", "192.169.0.1"));
     store.Add(new AddressRecord("foo.com", "192.169.0.2"));
     store.Add(new AddressRecord("foo.com", "192.169.0.3"));
     store.Add(new AddressRecord("bar.com", "192.168.0.1"));
     store.Add(new AddressRecord("goo.com", "192.167.0.1"));
     store.Add(new AddressRecord("goo.com", "192.167.0.2"));
     store.Add(new AddressRecord("localhost", "127.0.0.1"));
     store.Add(new AddressRecord("bigrecord.com", "1.2.3.4"));
     
     const string BigString = "0123456789abcdefghijklmnop";
     TextRecord txt = new TextRecord("goo.com", new string[] { BigString, "One_" + BigString, "Two_" + BigString});
     store.Add(txt);
     
     StringBuilder builder = new StringBuilder(64);
     for (int i = 0; i < 64; ++i)
     {
         builder.Append('a');
     }
     string bigTextString = builder.ToString();
     string[] textStrings = new string[128];
     for (int i = 0; i < textStrings.Length; ++i)
     {
         textStrings[i] = bigTextString;
     }
     store.Add(new TextRecord("bigrecord.com", textStrings)); 
     
     store.Add(new SRVRecord("foo.com", 20, 353, "x.y.z.com"));            
     store.Add(new MXRecord("goo.com", "foo.bar.xyz"));
 }