コード例 #1
0
ファイル: DnsResourceRecord.cs プロジェクト: blinds52/nhind
        /// <summary>
        /// Tests equality between this RR and the other <paramref name="record"/>
        /// </summary>
        /// <remarks>
        /// Compares all fields except TTL , since that can vary
        /// </remarks>
        /// <returns><c>true</c> if equal</returns>
        public virtual bool Equals(DnsResourceRecord record)
        {
            if (record == null)
            {
                return(false);
            }

            return(
                this.Type == record.Type &&
                this.Class == record.Class &&
                DnsStandard.Equals(this.Name, record.Name)
                );
        }
コード例 #2
0
ファイル: DnsQuestion.cs プロジェクト: ywangmaxmd/nhin-d
        /// <summary>
        /// Tests this instance for equality with the other <paramref name="question"/>
        /// </summary>
        /// <param name="question">The other question.</param>
        /// <returns><c>true</c> if the instances represent the same question, <c>false</c> otherwise.</returns>
        public bool Equals(DnsQuestion question)
        {
            if (question == null)
            {
                return(false);
            }

            return(
                DnsStandard.Equals(question.Domain, this.Domain) &&
                question.Type == this.Type &&
                question.Class == this.Class
                );
        }
コード例 #3
0
ファイル: DnsRecordTable.cs プロジェクト: DM-TOR/nhin-d
 public IEnumerable<DnsResourceRecord> this[string domainName, DnsStandard.RecordType type]
 {
     get
     {
         IEnumerable<DnsResourceRecord> matches = this[domainName];
         if (matches == null)
         {
             return null;
         }
         
         return (
                    from record in matches
                    where record.Type == type
                    select record
                );
     }
 }
コード例 #4
0
        public static void GetMatches(this RecordRetrievalServiceClient client, string domain, DnsResourceRecordCollection resourceRecords, DnsStandard.RecordType recordType)
        {
            DnsRecord[] matches = client.GetMatchingDnsRecords(domain, recordType);
            if (matches.IsNullOrEmpty())
            {
                return;
            }

            foreach (DnsRecord record in matches)
            {
                DnsResourceRecord responseRecord = record.Deserialize();
                if (responseRecord != null && responseRecord.Type == recordType)
                {
                    resourceRecords.Add(responseRecord);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Tests equality between this CERT 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);
            }

            CertRecord certRecord = record as CertRecord;

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

            return(
                this.m_algorithm == certRecord.m_algorithm &&
                this.m_certType == certRecord.m_certType &&
                this.m_keyTag == certRecord.m_keyTag &&
                DnsStandard.Equals(this.Cert.Name, certRecord.Cert.Name)
                );
        }
コード例 #6
0
ファイル: DnsResourceRecord.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// Instantiates a new Dns Resource Record
 /// </summary>
 /// <param name="name">the domain name for which this is a record</param>
 /// <param name="type">the record type</param>
 protected DnsResourceRecord(string name, DnsStandard.RecordType type)
 {
     this.Name = name;
     this.Type = type;
     this.Class = DnsStandard.Class.IN;
 }
コード例 #7
0
ファイル: DnsResourceRecord.cs プロジェクト: DM-TOR/nhin-d
        /// <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;
        }
コード例 #8
0
ファイル: DnsMessage.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// Instantiates a Dns Message
 /// </summary>
 /// <param name="qType"></param>
 /// <param name="qName"></param>
 protected DnsMessage(DnsStandard.RecordType qType, string qName)
     : this(new DnsQuestion(qName, qType, DnsStandard.Class.IN))
 {
 }
コード例 #9
0
ファイル: DnsQuestion.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// Initializes an instance for the specified domain and type
 /// </summary>
 /// <param name="domain">The domain we are querying.</param>
 /// <param name="type">The record type we are querying.</param>
 public DnsQuestion(string domain, DnsStandard.RecordType type)
     : this(domain, type, DnsStandard.Class.IN)
 {
 }
コード例 #10
0
ファイル: DnsQuestion.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// Initializes an instance for the specified domain and type
 /// </summary>
 /// <param name="domain">The domain we are querying.</param>
 /// <param name="type">The record type we are querying.</param>
 /// <param name="qClass">Use to define a non Internet DNS query</param>
 public DnsQuestion(string domain, DnsStandard.RecordType type, DnsStandard.Class qClass)
 {
     this.Domain = domain;
     this.Type = type;
     this.Class = qClass;
 }
コード例 #11
0
ファイル: DnsResponder.cs プロジェクト: DM-TOR/nhin-d
 DnsResponse ProcessError(DnsRequest request, DnsStandard.ResponseCode code)
 {
     DnsResponse errorResponse = new DnsResponse(request);
     errorResponse.Header.ResponseCode = code;
     return errorResponse;
 }
コード例 #12
0
 public DnsRecord[] GetLastDnsRecords(long lastRecordID, int maxResults, DnsStandard.RecordType typeID)
 {
     return  Store.DnsRecords.Get(lastRecordID
         , maxResults
         , typeID);
 }
コード例 #13
0
ファイル: DnsResponse.cs プロジェクト: DM-TOR/nhin-d
        internal int GetMinTTL(DnsStandard.RecordType recordType)
        {
            int minTTL = int.MaxValue;          // overall min ttl
            int minTTLType = int.MaxValue;      // min ttl for the given record type
            
            foreach(DnsResourceRecord record in this.AllRecords)
            {
                int newTTL = record.TTL;
                if (recordType == record.Type)
                {
                    if (newTTL < minTTLType)
                    {
                        minTTLType = newTTL;
                    }
                }
                if (newTTL < minTTL)
                {
                    minTTL = newTTL;
                }
            }
            
            if (minTTLType == int.MaxValue)
            {
                minTTLType = minTTL;
            }

            return (minTTLType == int.MaxValue || minTTLType < 0) ? 0 : minTTLType;
        }        
コード例 #14
0
 public int Count(DnsStandard.RecordType? recordType)
 {
     return Store.DnsRecords.Count(recordType);
 }
コード例 #15
0
ファイル: DnsException.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// Initializes an instace with the specified <paramref name="responseCode"/>
 /// </summary>
 /// <param name="responseCode">The server response code that triggered this exception.</param>
 public DnsServerException(DnsStandard.ResponseCode responseCode)
 {
     m_responseCode = responseCode;
 }
コード例 #16
0
        public void ResolveWithNameErrors(string domain, DnsStandard.RecordType type)
        {
            using (DnsClient client = s_authoritativeResolverServer.CreateClient())
            {
                DnsResponse response = client.Resolve(new DnsRequest(new DnsQuestion(domain, type)));

                Assert.False(response.HasAdditionalRecords);
                Assert.False(response.HasAnswerRecords);
                Assert.False(response.HasAnyRecords);
                Assert.True(response.IsNameError); 
            }
        }
コード例 #17
0
 public void ResolveSuccess(string domain, DnsStandard.RecordType type)
 {   
     using (DnsClient client = s_authoritativeResolverServer.CreateClient())
     {   
         switch (type)
         {
             case DnsStandard.RecordType.ANAME:
                 ResolveA(client, domain);
                 break; 
             case DnsStandard.RecordType.MX:
                 ResolveMX(client, domain); 
                 break; 
             case DnsStandard.RecordType.CERT:
                 ResolveCert(client, domain);                         
                 break; 
             default:
                 throw new NotSupportedException();
         }               
     }
 }
コード例 #18
0
 public DnsRecord[] EnumerateDnsRecordsByType(long lastID, int maxResults, DnsStandard.RecordType type)
 {
     try
     {
         return Store.DnsRecords.Get(lastID, maxResults, type);
     }
     catch (Exception ex)
     {
         throw CreateFault("EnumerateDnsRecordsByType", ex);
     }
 }
コード例 #19
0
 public DnsRecord[] GetMatchingDnsRecordsByType(string domainName
     , DnsStandard.RecordType typeID)
 {
     return Store.DnsRecords.Get(domainName
         , typeID);
 }