namespace Swan.Net.Dns { using System; using System.Net; using System.Text; /// /// Represents a DNS record entry. /// public class DnsRecord { /// /// Initializes a new instance of the class. /// /// The record. internal DnsRecord(DnsClient.IDnsResourceRecord record) : this() { Name = record.Name.ToString(); Type = record.Type; Class = record.Class; TimeToLive = record.TimeToLive; Data = record.Data; // PTR PointerDomainName = (record as DnsClient.DnsPointerResourceRecord)?.PointerDomainName?.ToString(); // A IPAddress = (record as DnsClient.DnsIPAddressResourceRecord)?.IPAddress; // NS NameServerDomainName = (record as DnsClient.DnsNameServerResourceRecord)?.NSDomainName?.ToString(); // CNAME CanonicalDomainName = (record as DnsClient.DnsCanonicalNameResourceRecord)?.CanonicalDomainName.ToString(); // MX MailExchangerDomainName = (record as DnsClient.DnsMailExchangeResourceRecord)?.ExchangeDomainName.ToString(); MailExchangerPreference = (record as DnsClient.DnsMailExchangeResourceRecord)?.Preference; // SOA SoaMasterDomainName = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.MasterDomainName.ToString(); SoaResponsibleDomainName = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.ResponsibleDomainName.ToString(); SoaSerialNumber = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.SerialNumber; SoaRefreshInterval = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.RefreshInterval; SoaRetryInterval = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.RetryInterval; SoaExpireInterval = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.ExpireInterval; SoaMinimumTimeToLive = (record as DnsClient.DnsStartOfAuthorityResourceRecord)?.MinimumTimeToLive; } private DnsRecord() { // placeholder } /// /// Gets the name. /// /// /// The name. /// public string Name { get; } /// /// Gets the type. /// /// /// The type. /// public DnsRecordType Type { get; } /// /// Gets the class. /// /// /// The class. /// public DnsRecordClass Class { get; } /// /// Gets the time to live. /// /// /// The time to live. /// public TimeSpan TimeToLive { get; } /// /// Gets the raw data of the record. /// /// /// The data. /// public byte[] Data { get; } /// /// Gets the data text bytes in ASCII encoding. /// /// /// The data text. /// public string DataText => Data == null ? string.Empty : Encoding.ASCII.GetString(Data); /// /// Gets the name of the pointer domain. /// /// /// The name of the pointer domain. /// public string PointerDomainName { get; } /// /// Gets the ip address. /// /// /// The ip address. /// public IPAddress IPAddress { get; } /// /// Gets the name of the name server domain. /// /// /// The name of the name server domain. /// public string NameServerDomainName { get; } /// /// Gets the name of the canonical domain. /// /// /// The name of the canonical domain. /// public string CanonicalDomainName { get; } /// /// Gets the mail exchanger preference. /// /// /// The mail exchanger preference. /// public int? MailExchangerPreference { get; } /// /// Gets the name of the mail exchanger domain. /// /// /// The name of the mail exchanger domain. /// public string MailExchangerDomainName { get; } /// /// Gets the name of the soa master domain. /// /// /// The name of the soa master domain. /// public string SoaMasterDomainName { get; } /// /// Gets the name of the soa responsible domain. /// /// /// The name of the soa responsible domain. /// public string SoaResponsibleDomainName { get; } /// /// Gets the soa serial number. /// /// /// The soa serial number. /// public long? SoaSerialNumber { get; } /// /// Gets the soa refresh interval. /// /// /// The soa refresh interval. /// public TimeSpan? SoaRefreshInterval { get; } /// /// Gets the soa retry interval. /// /// /// The soa retry interval. /// public TimeSpan? SoaRetryInterval { get; } /// /// Gets the soa expire interval. /// /// /// The soa expire interval. /// public TimeSpan? SoaExpireInterval { get; } /// /// Gets the soa minimum time to live. /// /// /// The soa minimum time to live. /// public TimeSpan? SoaMinimumTimeToLive { get; } } }