2019-12-08 21:23:54 +01:00
|
|
|
|
namespace Swan.Net.Dns {
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents a response from a DNS server.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DnsQueryResult {
|
|
|
|
|
private readonly List<DnsRecord> _mAnswerRecords = new List<DnsRecord>();
|
|
|
|
|
private readonly List<DnsRecord> _mAdditionalRecords = new List<DnsRecord>();
|
|
|
|
|
private readonly List<DnsRecord> _mAuthorityRecords = new List<DnsRecord>();
|
|
|
|
|
|
2019-12-04 18:57:18 +01:00
|
|
|
|
/// <summary>
|
2019-12-08 21:23:54 +01:00
|
|
|
|
/// Initializes a new instance of the <see cref="DnsQueryResult"/> class.
|
2019-12-04 18:57:18 +01:00
|
|
|
|
/// </summary>
|
2019-12-08 21:23:54 +01:00
|
|
|
|
/// <param name="response">The response.</param>
|
|
|
|
|
internal DnsQueryResult(DnsClient.IDnsResponse response) : this() {
|
|
|
|
|
this.Id = response.Id;
|
|
|
|
|
this.IsAuthoritativeServer = response.IsAuthorativeServer;
|
|
|
|
|
this.IsRecursionAvailable = response.IsRecursionAvailable;
|
|
|
|
|
this.IsTruncated = response.IsTruncated;
|
|
|
|
|
this.OperationCode = response.OperationCode;
|
|
|
|
|
this.ResponseCode = response.ResponseCode;
|
|
|
|
|
|
|
|
|
|
if(response.AnswerRecords != null) {
|
|
|
|
|
foreach(DnsClient.IDnsResourceRecord record in response.AnswerRecords) {
|
|
|
|
|
this.AnswerRecords.Add(new DnsRecord(record));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(response.AuthorityRecords != null) {
|
|
|
|
|
foreach(DnsClient.IDnsResourceRecord record in response.AuthorityRecords) {
|
|
|
|
|
this.AuthorityRecords.Add(new DnsRecord(record));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(response.AdditionalRecords != null) {
|
|
|
|
|
foreach(DnsClient.IDnsResourceRecord record in response.AdditionalRecords) {
|
|
|
|
|
this.AdditionalRecords.Add(new DnsRecord(record));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DnsQueryResult() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The identifier.
|
|
|
|
|
/// </value>
|
|
|
|
|
public System.Int32 Id {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether this instance is authoritative server.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// <c>true</c> if this instance is authoritative server; otherwise, <c>false</c>.
|
|
|
|
|
/// </value>
|
|
|
|
|
public System.Boolean IsAuthoritativeServer {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether this instance is truncated.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// <c>true</c> if this instance is truncated; otherwise, <c>false</c>.
|
|
|
|
|
/// </value>
|
|
|
|
|
public System.Boolean IsTruncated {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether this instance is recursion available.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// <c>true</c> if this instance is recursion available; otherwise, <c>false</c>.
|
|
|
|
|
/// </value>
|
|
|
|
|
public System.Boolean IsRecursionAvailable {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the operation code.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The operation code.
|
|
|
|
|
/// </value>
|
|
|
|
|
public DnsOperationCode OperationCode {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the response code.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The response code.
|
|
|
|
|
/// </value>
|
|
|
|
|
public DnsResponseCode ResponseCode {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the answer records.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The answer records.
|
|
|
|
|
/// </value>
|
|
|
|
|
public IList<DnsRecord> AnswerRecords => this._mAnswerRecords;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the additional records.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The additional records.
|
|
|
|
|
/// </value>
|
|
|
|
|
public IList<DnsRecord> AdditionalRecords => this._mAdditionalRecords;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the authority records.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The authority records.
|
|
|
|
|
/// </value>
|
|
|
|
|
public IList<DnsRecord> AuthorityRecords => this._mAuthorityRecords;
|
|
|
|
|
}
|
2019-12-04 18:57:18 +01:00
|
|
|
|
}
|