/// <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) ); }
/// <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 ); }
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 ); } }
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); } } }
/// <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) ); }
/// <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; }
/// <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; }
/// <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)) { }
/// <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) { }
/// <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; }
DnsResponse ProcessError(DnsRequest request, DnsStandard.ResponseCode code) { DnsResponse errorResponse = new DnsResponse(request); errorResponse.Header.ResponseCode = code; return errorResponse; }
public DnsRecord[] GetLastDnsRecords(long lastRecordID, int maxResults, DnsStandard.RecordType typeID) { return Store.DnsRecords.Get(lastRecordID , maxResults , typeID); }
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; }
public int Count(DnsStandard.RecordType? recordType) { return Store.DnsRecords.Count(recordType); }
/// <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; }
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); } }
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(); } } }
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); } }
public DnsRecord[] GetMatchingDnsRecordsByType(string domainName , DnsStandard.RecordType typeID) { return Store.DnsRecords.Get(domainName , typeID); }